1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| procedure TFGrapher.ICurveGesture(Sender: TObject;
const [Ref] EventInfo: TGestureEventInfo; var Handled: Boolean);
var
zoom: extended;
DeltaDistance: Integer;
Translation: TPointF;
begin
Passage:=Passage+1;
Label1.Text:=inttostr(Passage);
// double tap
if (EventInfo.GestureID = igiDoubleTap) then
begin
YMax := 10;
YMin := -10;
XMin := -5.2;
XMax := 5.2;
FGrapher.ICurve.Repaint;
Handled := true;
end;
// zoom
if (EventInfo.GestureID = igiZoom) then
Begin
if TInteractiveGestureFlag.gfBegin in EventInfo.Flags then
begin
LastDistance := EventInfo.Distance;
// distance entre les 2 doigts
end;
if not(TInteractiveGestureFlag.gfBegin in EventInfo.Flags) and
not(TInteractiveGestureFlag.gfEnd in EventInfo.Flags) then
begin
DeltaDistance := LastDistance - EventInfo.Distance;
zoom := (XMax - XMin) * DeltaDistance / (CurveWidth);
XMin := XMin - zoom;
XMax := XMax + zoom;
YMin := YMin - zoom;
YMax := YMax + zoom;
FGrapher.ICurve.Repaint;
LastDistance := EventInfo.Distance;
Handled := true;
end;
if TInteractiveGestureFlag.gfEnd in EventInfo.Flags then
begin
FGrapher.ICurve.Repaint;
Handled := true;
end;
end;
// pan
if (EventInfo.GestureID = igiPan) then
Begin
if TInteractiveGestureFlag.gfBegin in EventInfo.Flags then
begin
LastPos := EventInfo.Location;
// distance entre les 2 doigts
end;
if not(TInteractiveGestureFlag.gfBegin in EventInfo.Flags) and
not(TInteractiveGestureFlag.gfEnd in EventInfo.Flags) then
begin
Translation.X := (LastPos.X - EventInfo.Location.X) * (XMax - XMin) /
CurveWidth;
Translation.Y := (LastPos.Y - EventInfo.Location.Y) * (YMax - YMin) /
CurveHeight;
XMin := XMin + Translation.X;
XMax := XMax + Translation.X;
YMin := YMin - Translation.Y;
YMax := YMax - Translation.Y;
FGrapher.ICurve.Repaint;
LastPos := EventInfo.Location;
Handled := true;
end;
if TInteractiveGestureFlag.gfEnd in EventInfo.Flags then
begin
FGrapher.ICurve.Repaint;
Handled := true;
End;
end;
end; |
Partager