Flutter 自定义控件-仿照安卓和抖音图标绘制(1),含小米、腾讯、阿里

…strokeWidth = 60.0 / 3

…color = Colors.redAccent; //背景为纸红色

rect = Rect.fromCircle(center: Offset(size.width / 2, size.height / 2), radius: 30.0);

canvas.drawArc(rect, 0, math.pi * 3 / 2, false, paint);

}

@override

bool shouldRepaint(CustomPainter oldDelegate) => true;

}

class MyTrillPainter extends CustomPainter {

@override

void paint(Canvas canvas, Size size) {

var paint = Paint()

…isAntiAlias = true

…style = PaintingStyle.fill //

…strokeWidth = 1.0

…color = Colors.black; //背景为纸红色

// 设置矩形的半径和圆角的半径相等,效果如下面右图

Rect rect = Rect.fromLTRB(55.0, 30.0, 255.0, 220.0);

RRect rRect = RRect.fromRectAndRadius(rect, Radius.circular(20.0));

canvas.drawRRect(rRect, paint);

paint

…style = PaintingStyle.stroke //

…strokeWidth = 60.0 / 3

…color = Colors.redAccent; //背景为纸红色

rect = Rect.fromCircle(center: Offset(size.width / 2, size.height / 2), radius: 30.0);

canvas.drawArc(rect, 0, math.pi * 3 / 2, false, paint);

canvas.drawLine(Offset(size.width / 2 + 30.0, size.height / 2), Offset(size.width / 2 + 30.0, size.height / 2 - 84.0), paint);

}

@override

bool shouldRepaint(CustomPainter oldDelegate) => true;

}

class MyTrillPainter extends CustomPainter {

@override

void paint(Canvas canvas, Size size) {

var paint = Paint()

…isAntiAlias = true

…style = PaintingStyle.fill //

…strokeWidth = 1.0

…color = Colors.black; //背景为纸红色

// 设置矩形的半径和圆角的半径相等,效果如下面右图

Rect rect = Rect.fromLTRB(55.0, 30.0, 255.0, 220.0);

RRect rRect = RRect.fromRectAndRadius(rect, Radius.circular(20.0));

canvas.drawRRect(rRect, paint);

paint

…style = PaintingStyle.stroke //

…strokeWidth = 60.0 / 3

…color = Colors.redAccent; //背景为纸红色

rect = Rect.fromCircle(center: Offset(size.width / 2 + 60.0, size.height / 2 - 80.0), radius: 30.0);

canvas.drawArc(rect, math.pi * 1, -math.pi * 0.5, false, paint);

}

@override

bool shouldRepaint(CustomPainter oldDelegate) => true;

}

3、绘制青色区域

class MyTrillPainter extends CustomPainter {

@override

void paint(Canvas canvas, Size size) {

var paint = Paint()

…isAntiAlias = true

…style = PaintingStyle.fill //

…strokeWidth = 1.0

…color = Colors.black; //背景为纸红色

// 设置矩形的半径和圆角的半径相等,效果如下面右图

Rect rect = Rect.fromLTRB(55.0, 30.0, 255.0, 220.0);

RRect rRect = RRect.fromRectAndRadius(rect, Radius.circular(20.0));

canvas.drawRRect(rRect, paint);

paint

…style = PaintingStyle.stroke //

…strokeWidth = 60.0 / 3

…color = Colors.redAccent; //背景为纸红色

rect = Rect.fromCircle(center: Offset(size.width / 2, size.height / 2), radius: 30.0);

canvas.drawArc(rect, 0, math.pi * 3 / 2, false, paint);

canvas.drawLine(Offset(size.width / 2 + 30.0, size.height / 2), Offset(size.width / 2 + 30.0, size.height / 2 - 84.0), paint);

rect = Rect.fromCircle(center: Offset(size.width / 2 + 60.0, size.height / 2 - 80.0), radius: 30.0);

canvas.drawArc(rect, math.pi * 1, -math.pi * 0.5, false, paint);

rect = Rect.fromCircle(center: Offset(size.width / 2 - 7.0, size.height / 2 - 9.0), radius: 30.0);

canvas.drawArc(rect, 0, math.pi * 3 / 2 + 0.1, false, paint…color = Colors.cyanAccent);

canvas.drawLine(Offset(size.width / 2 + 30.0 - 7.0, size.height / 2 - 9.0), Off

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值