home *** CD-ROM | disk | FTP | other *** search
- (***********************************************************)
- (* *)
- (* TURBO GRAPHIX version 1.06A *)
- (* *)
- (* World coordinate system finder module *)
- (* Module version 1.06A *)
- (* *)
- (* Copyright (C) 1985 by *)
- (* BORLAND International *)
- (* *)
- (***********************************************************)
-
- procedure FindWorld(I : integer; A : PlotArray; NPoints : integer;
- ScaleX, ScaleY : real);
- var
- J : integer;
- Xmax, Ymax, Xmin, Ymin, Xmid, Ymid, Xdiff, Ydiff : real;
-
- begin
- NPoints := abs(NPoints);
- if NPoints >= 2 then
- if I in [1..MaxWorldsGlb] then
- begin
- Xmax := A[1, 1];
- Ymax := A[1, 2];
- Xmin := Xmax;
- Ymin := Ymax;
- for J := 2 to NPoints do
- begin
- if A[J, 1] > Xmax then
- Xmax := A[J, 1]
- else
- if A[J, 1] < Xmin then
- Xmin := A[J, 1];
- if A[J, 2] > Ymax then
- Ymax := A[J, 2]
- else
- if A[J, 2] < Ymin then
- Ymin := A[J, 2];
- end;
- ScaleX := abs(ScaleX);
- ScaleY := abs(ScaleY);
- Xdiff := Xmax - Xmin;
- Xmid := (Xmax + Xmin) * 0.5;
- Xmax := Xmid + ScaleX * 0.5 * Xdiff;
- Xmin := Xmid - ScaleX * 0.5 * Xdiff;
- Ydiff := Ymax - Ymin;
- Ymid := (Ymax + Ymin) * 0.5;
- Ymax := Ymid + ScaleY * 0.5 * Ydiff;
- Ymin := Ymid - ScaleY * 0.5 * Ydiff;
- DefineWorld(I, Xmin, Ymin, Xmax, Ymax);
- SelectWorld(I);
- end
- else
- Error(7, 2)
- else
- Error(7, 4);
- end; { FindWorld }