画图

作者: follow_er | 来源:发表于2022-09-14 14:08 被阅读0次

画笔

p = Paint()
  ..color = Colors.orange // 画笔的颜色
  ..strokeWidth = 2.0 // 线的宽度
  ..style = PaintingStyle.stroke // fill: 填充, stroke: 空心
  ..strokeCap = StrokeCap.butt // 转折处的处理
  ..blendMode = BlendMode.dstIn; // 重叠处的处理模式,clear,src, dst, srcIn,dstIn等等。

Demo

样式示例图


image.png
class MyCirclePainterPaintModel {
  Color color; //画笔色
  double progress; //进度 1为全部

  MyCirclePainterPaintModel ({
    this.color,
    this.progress,
  });
}

class MyCirclePainter extends CustomPainter {
  double radius; //半径
  double strokeWidth; //画笔宽度
  Color bgColor; //底部背景色
  List <MyCirclePainterPaintModel> paints;
  MyCirclePainter ({
    this.radius = 50.0,
    this.strokeWidth = 12.0,
    this.bgColor =  Colors.grey,
    this.paints,
});

  @override
  void paint(Canvas canvas, Size size) {
    Offset offset = Offset(size.width*0.5, size.height * 0.5);
    var paint = Paint()
      ..color = Colors.grey
      ..style = PaintingStyle.stroke
      ..strokeWidth = strokeWidth;
    canvas.drawCircle(offset, radius, paint);
    if (paints != null && paints.length > 0) {
      double initSweepAngle = -90 * pi / 180; //初始开始角度
      for (var mPaint in paints) {
        var paint = Paint();
        paint
          ..color = mPaint.color
          ..strokeWidth = strokeWidth
          ..style = PaintingStyle.stroke
          ..strokeCap = StrokeCap.round;
        Rect rect = Rect.fromCenter(center: offset, width: radius * 2, height: radius * 2);
        double sweepAngle = mPaint.progress * 360; //完成角度
        double radian = sweepAngle * pi / 180;
        canvas.drawArc(rect, initSweepAngle, radian, false, paint);
        initSweepAngle += radian;
      }
    }
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) {
    return false;
  }

}

相关文章

  • 2018-05-19

    画图,画图,画图!我画完了哦[偷笑]

  • 微信小程序Canvas

    新版 画图片 旧版 画图

  • 唯美漫画图片分享图包下载

    唯美漫画图片 唯美漫画图片 唯美漫画图片 唯美漫画图片 唯美漫画图片 唯美漫画图片 更多唯美漫画图片请关注微信公众...

  • 画图狗的独白

    我是一条资深画图狗…… 毫不夸张的说,到了画图周忙的昏天黑地,吃饭喝水睡觉都会忘记……只有画图画图画图,模型模型模...

  • 画图

    周五早会技术员通知,下周一每人交岗位练兵记录本。 从五月初就下发通知,每人每周练兵五道题并画一张岗位工艺流程图。但...

  • 画图

    图片是照着网上临摹的,先起个草稿。 这个我选择从腿开始网上处理。 鼠标不好控制,杂线很多,就跟裁衣服似的,最后再清...

  • 画图

  • 画图

    今天女儿作业完成较早,九点之前完成检查签字,其他时间由她自主安排。由于感冒不太舒服,我准备躺下休息会儿,这时便听见...

  • 画图

    画了一个母亲大人家的关系图,存一下。

  • 画图

网友评论

      本文标题:画图

      本文链接:https://www.haomeiwen.com/subject/hcgkortx.html