sha*_*arl 27 android paint touch-event
我想用这样的发光效果绘制线条
问题 - 我必须根据用户的交互在程序中生成这一行(行的形式将在onTouchEvent- 中生成ACTION_MOVE).
我可以在没有xml文件或绘制premaid位图的情况下生成此效果吗?
sha*_*arl 64
我用这种方式模仿这个效果:
BlurMaskFilter;我使用Path类来生成行并保存MOVE_ACTION事件的坐标,以仅生成我需要的路径的一部分.
创建2 Paint()秒:
_paintSimple = new Paint();
_paintSimple.setAntiAlias(true);
_paintSimple.setDither(true);
_paintSimple.setColor(Color.argb(248, 255, 255, 255));
_paintSimple.setStrokeWidth(20f);
_paintSimple.setStyle(Paint.Style.STROKE);
_paintSimple.setStrokeJoin(Paint.Join.ROUND);
_paintSimple.setStrokeCap(Paint.Cap.ROUND);
_paintBlur = new Paint();
_paintBlur.set(_paintSimple);
_paintBlur.setColor(Color.argb(235, 74, 138, 255));
_paintBlur.setStrokeWidth(30f);
_paintBlur.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.NORMAL));
Run Code Online (Sandbox Code Playgroud)
我画了两次Path():
@Override
protected void onDraw(Canvas canvas) {
canvas.drawPath(mPath, _paintBlur);
canvas.drawPath(mPath, _paintSimple);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14496 次 |
| 最近记录: |