From f73c95edec4c27f24d59e2481ef143b8567c57cf Mon Sep 17 00:00:00 2001 From: ronaldhordijk Date: Sun, 5 Jun 2005 07:22:41 +0000 Subject: [PATCH] zoom out added --- 2.10/Source/ControlPoint.pas | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/2.10/Source/ControlPoint.pas b/2.10/Source/ControlPoint.pas index 4dc93b3..f6ba077 100644 --- a/2.10/Source/ControlPoint.pas +++ b/2.10/Source/ControlPoint.pas @@ -121,6 +121,7 @@ type destructor Destroy; override; procedure ZoomtoRect(R: TRect); + procedure ZoomOuttoRect(R: TRect); procedure ZoomIn(Factor: double); procedure MoveRect(R: TRect); procedure Rotate(Angle: double); @@ -1136,7 +1137,7 @@ begin if ((maxx - minx) > 1000) or ((maxy - miny) > 1000) then - raise EMathError.Create('Flame area to large'); + raise EMathError.Create('Flame area too large'); cp.center[0] := (minx + maxx) / 2; cp.center[1] := (miny + maxy) / 2; @@ -1627,6 +1628,27 @@ begin Zoom := Log2(Scale); end; +/////////////////////////////////////////////////////////////////////////////// +procedure TControlPoint.ZoomOuttoRect(R: TRect); +var + scale: double; + ppux, ppuy: double; + dx,dy: double; +begin + scale := power(2, zoom); + ppux := pixels_per_unit * scale; + ppuy := pixels_per_unit * scale; + + dx := ((r.Left + r.Right)/2 - Width/2)/ppux ; + dy := ((r.Top + r.Bottom)/2 - Height/2)/ppuy; + + center[0] := center[0] + cos(FAngle) * dx - sin(FAngle) * dy; + center[1] := center[1] + sin(FAngle) * dx + cos(FAngle) * dy ; + + Scale := Scale * Min( Width/(abs(r.Right - r.Left) + 1), Height/(abs(r.Bottom - r.Top) + 1)) ; + Zoom := Log2(1/Scale); +end; + /////////////////////////////////////////////////////////////////////////////// procedure TControlPoint.ZoomIn(Factor: double); var