如何在手机屏幕上徒手画线?
我在手势EventInfo.GestureID -- igipan 事件中画图,发现拒绝Image画图操作。
http://blog.sina.com.cn/s/blog_44fa172f0102vynt.html
自定义View, 重写onDraw等方法,拦截手势,刷新ui绘图
怎样确定徒手画的起笔点?感谢!!
procedure TForm1.Image1Gesture(Sender: TObject;
const [Ref] EventInfo: TGestureEventInfo; var Handled: Boolean);
begin
case EventInfo.GestureID of
igipan:
begin
image1.Bitmap.Canvas.BeginScene(nil,0);
image1.Bitmap.Canvas.Stroke.Color:=$ffff0000;
image1.Bitmap.Canvas.DrawLine(Locat0,EventInfo.Location,1);
image1.Bitmap.Canvas.EndScene;
Locat0:=EventInfo.Location;
end;
end;
这段可以徒手画曲线。但初始点总是从“Locat0”开始,造成起笔带着一段直线。
在Tap事件加入Locat0:=Point;,没有效果。感觉手势事件比Tap 事件优先执行。
procedure TForm1.Image1Tap(Sender: TObject; const [Ref] Point: TPointF);
begin
Locat0:=Point;
end;
画图的代码要放在
Canvas.BeginScene和**Canvas.EndScene**之间
刚做过一个项目用到过徒手画
注意二点就可以完成,1、起笔点坐标用 MouseDown , 2要有个提笔清空坐标(坐标为0)用MouseUp 画时