【问题标题】:Using Flutter's CustomPaint, is it possible to draw a transparent path with solid color edge?使用 Flutter 的 CustomPaint,是否可以绘制纯色边缘的透明路径?
【发布时间】:2021-07-26 13:18:05
【问题描述】:

我正在使用 Flutter 开发绘图应用程序。如何绘制透明颜色的路径和路径周围的纯色边缘?

【问题讨论】:

    标签: flutter path draw paint transparent


    【解决方案1】:

    我尝试了不同的混合模式,但无法达到我想要的效果,所以我按照以下方式实现。这是一项昂贵的操作,但可以按预期工作。

    双 iw=20; 双 ow=25;

    Path mPath1=Path;
    Path mPath2=Path;
    
    Color color_alpha=Color.fromARGB(10,255,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, pt.dy), width: ow, height: ow));
    }
    
    canvas.drawPath(Path.combine(PathOperation.difference, mPath2, mPath1), Paint());
    canvas.drawPath(mPath1, Paint..color=color_alpha);
    

    这是结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-09-09
      • 1970-01-01
      • 2015-04-08
      • 2011-08-31
      • 2018-07-18
      • 1970-01-01
      • 2017-01-29
      相关资源
      最近更新 更多