0

我尝试通过带有 alpha Gradient 的 drawLine() 绘制彗星,但线条不会像这张图片中那样完美连接:

http://s14.postimg.org/y5w6pgl6p/Scr​​eenshot_2013_07_09_16_14_21.png

路径可能像 S 形或 C 形或(继续移动)

使用此代码:

paint.setStrokeJoin(Paint.Join.BEVEL);
paint.setStrokeWidth(20);
paint.setShader(new LinearGradient(100,200,150,200, 0x00ffff00,0x44ffff00, Shader.TileMode.CLAMP));
canvas.drawLine(100, 200, 150, 200, paint);
paint.setShader(new LinearGradient(150,200,200,220, 0x44ffff00,0x88ffff00, Shader.TileMode.CLAMP));
canvas.drawLine(150, 200, 200, 220, paint);
paint.setShader(new LinearGradient(200, 220, 230, 230, 0x88ffff00, 0xccffff00, Shader.TileMode.CLAMP));
canvas.drawLine(200, 220, 230, 260, paint);
paint.setShader(new LinearGradient(230, 230, 230, 280, 0xccffff00, 0xffffff00, Shader.TileMode.CLAMP));
canvas.drawLine(230,260,230,310,paint);

setStrokeJoin() 对 drawLine/s 没有帮助

我将线条转换为路径,但渐变没有随整个路径弯曲

我还绘制形状而不是线条,以填充它们之间的空白空间,但是在动画线条上绘制需要花费大量时间和 CPU。

还有其他想法吗?

4

1 回答 1

1
Path path = new Path();
path.moveTo(100, 200);
path.lineTo(150, 200);
path.lineTo(200, 220);
path.lineTo(230, 260);
path.lineTo(230,310);
Paint paint = new Paint();
paint.setShader(new LinearGradient(100,200,230,310, 0x00ffff00,0x44ffff00, TileMode.CLAMP));
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(50);
canvas.drawPath(path, paint);

希望能帮助到你!

于 2013-07-25T10:06:52.207 回答