首页 > 其他分享 >flutter 画一条曲线

flutter 画一条曲线

时间:2022-11-29 11:42:09浏览次数:47  
标签:一条 false .. 画笔 曲线 50 paint MyPainter flutter


1、代码

Container( width: 50, height: 50, child: CustomPaint( size: Size(50, 50), painter: MyPainter(), isComplex: false, willChange: false, child: Container(), ), ); class MyPainter extends CustomPainter { MyPainter(); ///[定义画笔] Paint _paint = Paint() ..color = Colors.red //画笔颜色 ..strokeCap = StrokeCap.round //画笔笔触类型 ..isAntiAlias = true //是否启动抗锯齿 ..style = PaintingStyle.stroke //绘画风格,默认为填充 ..strokeWidth = 1.0; //画笔的宽度 @override void paint(Canvas canvas, Size size) { // Rect来确认圆弧的位置,还需要开始的弧度、结束的弧度、是否使用中心点绘制、以及paint弧度 const PI = 3.1415926; Rect rect = Rect.fromCircle(center: Offset(15, 16), radius: 10); canvas.drawArc(rect, -2.8, PI, false, _paint); } @override bool shouldRepaint(CustomPainter oldDelegate) { return null; } }

 

 

2、效果图

flutter 画一条曲线_抗锯齿

 

 

标签:一条,false,..,画笔,曲线,50,paint,MyPainter,flutter
From: https://blog.51cto.com/u_13002884/5894583

相关文章