Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我画了一个填充路径(形状)
canvas.drawPath(mypath, paint);
这工作正常。现在我的问题:我想要一个特殊的效果,颜色的不透明度降低到路径的边界(形状)。所以在形状的中心,不透明度将是 100% 并且到边界颜色淡出到 0% ( 0 opacity )
有没有人提示我如何做到这一点?
这是不可行的,除非路径是一个简单的类似椭圆的形状(在这种情况下,您可以使用 RadialGradient 填充它)。
另一种选择是将内部模糊 MaskFilter 设置为油漆,如下所示:
float blurRadius = 10; paint.setMaskFilter(new BlurMaskFilter(blurRadius, BlurMaskFilter.Blur.NORMAL));
在模糊的情况下,结果也高度依赖于路径形状。