home *** CD-ROM | disk | FTP | other *** search
- (***********************************************************)
- (* *)
- (* TURBO GRAPHIX version 1.06A *)
- (* *)
- (* Crosshatch module *)
- (* Module version 1.06A *)
- (* *)
- (* Copyright (C) 1985 by *)
- (* BORLAND International *)
- (* *)
- (***********************************************************)
-
- procedure Hatch(X_1, Y_1, X_2, Y_2, Delta : real);
- var
- X1, Y1, X2, Y2 : integer;
- DirectModeLoc, Dummy : boolean;
-
- procedure HatchDirect(X1, Y1, X2, Y2, Delta : integer);
- var
- I, Yst, Yen, Count : integer;
- X1RefLoc, X2RefLoc, Y1RefLoc, Y2RefLoc : integer;
- DirectModeLoc, ClippingLoc : boolean;
- X1D, Y1D, X2D, Y2D : integer;
-
- begin { HatchDirect }
- if Delta <> 0 then
- begin
- HatchGlb := true;
- DirectModeLoc := DirectModeGlb;
- DirectModeGlb := true;
- ClippingLoc := ClippingGlb;
- ClippingGlb := true;
- X1RefLoc := X1RefGlb;
- X1RefGlb := X1;
- X2RefLoc := X2RefGlb;
- X2RefGlb := X2;
- Y1RefLoc := Y1RefGlb;
- Y1RefGlb := Y1;
- Y2RefLoc := Y2RefGlb;
- Y2RefGlb := Y2;
- Yst := Y1 + Delta;
- Yen := Y1 - X2 + X1 + Delta;
- if Delta < 0 then
- begin
- Delta := -Delta;
- I := Yst;
- Yst := Yen;
- Yen := I;
- end;
- Count := (Y2 - Y1 + X2 - X1 + X2 - X1) div Delta;
- for I := 1 to Count-1 do
- begin
- X1D := X1;
- Y1D := Yst;
- X2D := X2;
- Y2D := Yen;
- if Clip(X1D, Y1D, X2D, Y2D) then
- DrawLine(X1D, Y1D, X2D, Y2D);
- Yst := Yst + Delta;
- Yen := Yen + Delta;
- end;
- ClippingGlb := ClippingLoc;
- HatchGlb := false;
- X1RefGlb := X1RefLoc;
- X2RefGlb := X2RefLoc;
- Y1RefGlb := Y1RefLoc;
- Y2RefGlb := Y2RefLoc;
- DirectModeGlb := DirectModeLoc;
- end;
- end; { HatchDirect }
-
- begin { Hatch }
- if DirectModeGlb then
- HatchDirect(trunc(X_1), trunc(Y_1), trunc(X_2), trunc(Y_2), trunc(Delta))
- else
- begin
- DirectModeLoc := DirectModeGlb;
- DirectModeGlb := true;
- X1 := WindowX(X_1);
- Y1 := WindowY(Y_1);
- X2 := WindowX(X_2);
- Y2 := WindowY(Y_2);
- Dummy := Clip(X1, Y1, X2, Y1);
- Dummy := Clip(X1, Y1, X1, Y2);
- HatchDirect(X1, Y1, X2, Y2, trunc(Delta));
- DirectModeGlb := DirectModeLoc;
- end;
- end; { Hatch }