辉光有效动态生成的行 [英] Dynamically generated line with glow effective
本文介绍了辉光有效动态生成的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要画线像这样
光晕效果
这个问题 - ACTION_MOVE $ C - 我必须生成该行计划在依赖用户的交互(线的形式将
的onTouchEvent
生成$ C>)。
I want to draw line with glow effect like this
The problem - i must generate this line in program in dependence on user's interaction ( the form of line will be generated in onTouchEvent
- ACTION_MOVE
).
我可以生成这一效果的XML文件或绘图premaid位图?
Can i generate this effect without xml files or drawing premaid bitmap ?
推荐答案
我模仿这种效果是这样的:
I imitate this effect in this way :
- 与
BlurMaskFilter
绘制行 - 在画了它正常的线路。
- Draw line with
BlurMaskFilter
- Draw over it normal line.
我使用Path类来生成线,节省 MOVE_ACTION
的坐标事件生成路径的一部分我需要什么。
I use Path class to generate line and save coordinates of MOVE_ACTION
event to generate only part of path what i need.
创建2 油漆()
S:
_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));
和借鉴两次我路径()
:
@Override
protected void onDraw(Canvas canvas) {
canvas.drawPath(mPath, _paintBlur);
canvas.drawPath(mPath, _paintSimple);
}
这篇关于辉光有效动态生成的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文