问题描述
我正在使用 Flutter 开发绘图应用程序。如何绘制一条具有透明颜色的路径,并在路径周围绘制一条纯色边缘?
解决方法
我尝试了不同的混合模式,但无法实现我想要的效果,所以我采用以下方式实现。这是一个昂贵的操作,但它按预期工作。
双 iw=20; 双流=25;
Path mPath1=Path;
Path mPath2=Path;
Color color_alpha=Color.fromARGB(10,255,255);
for(int i=0; i< points.length; i++)
{
mPath1.addOval(Rect.fromCenter(center: Offset(pt.dx,pt.dy),width: iw,height: iw));
mPath2.addOval(Rect.fromCenter(center: Offset(pt.dx,width: ow,height: ow));
}
canvas.drawPath(Path.combine(PathOperation.difference,mPath2,mPath1),Paint());
canvas.drawPath(mPath1,Paint..color=color_alpha);
这是结果。