home *** CD-ROM | disk | FTP | other *** search
- (* ------------------------------------------------------ *)
- (* VERZERRE.PAS *)
- (* Programm zum Verzerren von beliebigen Bildschirm- *)
- (* bereichen. *)
- (* (c) 1991 Raimond Reichert & TOOLBOX *)
- (* ------------------------------------------------------ *)
- PROGRAM Bildschirmbereiche_verzerren;
-
- USES Graph, Crt, Dos;
-
- TYPE
- ImageRec = RECORD
- Size : INTEGER;
- Img : POINTER;
- END;
-
- CONST
- AK : INTEGER = 50;
- PutMode : BYTE = NotPut;
- TargetPage : BYTE = 0;
- DeleteOld : BOOLEAN = FALSE;
- AktPage : BYTE = 0;
-
- VAR
- GraphMode,
- GraphDriver : INTEGER;
- GraphPath : STRING;
-
-
- PROCEDURE CatchImage(x1, y1, x2, y2 : INTEGER;
- VAR ImgVar : ImageRec);
- BEGIN
- WITH ImgVar DO BEGIN
- Img := NIL;
- Size := ImageSize(x1, y1, x2, y2);
- GetMem(Img, Size);
- GetImage(x1, y1, x2, y2, Img^);
- END;
- END;
-
- PROCEDURE FreeImage(VAR ImgVar : ImageRec);
- BEGIN
- IF ImgVar.Img <> NIL THEN BEGIN
- FreeMem(ImgVar.Img, ImgVar.Size);
- ImgVar.Size := 0;
- ImgVar.Img := NIL;
- END;
- END;
-
- PROCEDURE Verzerre(x1, y1, x2, y2 : INTEGER;
- tx1, ty1, StepY, StepX : INTEGER;
- SourcePage : BYTE);
- VAR
- im : ImageRec;
- j : INTEGER;
- BEGIN
- IF (tx1 = -1) AND (ty1 = -1) THEN BEGIN
- tx1 := x1; ty1 := y1;
- END;
- FOR j := 1 TO (x2-x1) DIV StepX+1 DO BEGIN
- SetActivePage(SourcePage);
- CatchImage(x1 + StepX*j - StepX+1, y1,
- x1 + StepX*j, y2, im);
- SetActivePage(TargetPage);
- PutImage(tx1 + StepX*j - StepX+1,
- ty1 + j*StepY, im.Img^, PutMode);
- IF DeleteOld THEN BEGIN
- SetActivePage(SourcePage);
- PutImage(x1 + StepX*j - StepX+1,
- y1, im.Img^, XorPut);
- END;
- FreeImage(im);
- END;
- END;
-
- PROCEDURE CosKurve(x1, y1, x2, y2 : INTEGER;
- tx1, ty1, Height : INTEGER;
- SourcePage : BYTE);
- VAR
- im : ImageRec;
- j : INTEGER;
- BEGIN
- IF (tx1 = -1) AND (ty1 = -1) THEN BEGIN
- tx1 := x1; ty1 := y1;
- END;
- FOR j := 0 TO (x2-x1)+1 DO BEGIN
- SetActivePage(SourcePage);
- CatchImage(x1+j, y1, x1+j, y2, im);
- SetActivePage(TargetPage);
- PutImage(tx1+j,
- ty1 + Round(Height*
- Cos((0-(x2-x1) DIV 2+j)/AK)),
- im.Img^, PutMode);
- IF DeleteOld THEN BEGIN
- SetActivePage(SourcePage);
- PutImage(x1+j, y1, im.Img^, XorPut);
- END;
- FreeImage(im);
- END;
- SetActivePage(AktPage);
- END;
-
- PROCEDURE SinKurve(x1, y1, x2, y2 : INTEGER;
- tx1, ty1, Height : INTEGER;
- SourcePage : BYTE);
- VAR
- im : ImageRec;
- j : INTEGER;
- BEGIN
- IF (tx1 = -1) AND (ty1 = -1) THEN BEGIN
- tx1 := x1; ty1 := y1;
- END;
- FOR j := 0 TO (x2-x1)+1 DO BEGIN
- SetActivePage(SourcePage);
- CatchImage (x1+j,y1,x1+j,y2,im);
- SetActivePage (TargetPage);
- PutImage(tx1+j,
- ty1 + Round(Height*
- Sin((0-(x2-x1) DIV 2+j)/AK)),
- im.Img^, PutMode);
- IF DeleteOld THEN BEGIN
- SetActivePage(SourcePage);
- PutImage(x1+j, y1, im.Img^, XorPut)
- END;
- FreeImage(im);
- END;
- SetActivePage(AktPage);
- END;
-
- PROCEDURE ArcTanKurve(x1, y1, x2, y2 : INTEGER;
- tx1, ty1, Height : INTEGER;
- SourcePage : BYTE);
- VAR
- im : ImageRec;
- j : INTEGER;
- BEGIN
- IF (tx1 = -1) AND (ty1 = -1) THEN BEGIN
- tx1 := x1; ty1 := y1
- END;
- FOR j := 0 TO (x2-x1)+1 DO BEGIN
- SetActivePage(SourcePage);
- CatchImage(x1+j, y1, x1+j, y2, im);
- SetActivePage(TargetPage);
- PutImage(tx1 + j,
- ty1 + Round(Height*
- ArcTan((0-(x2-x1) DIV 2+j)/AK)),
- im.Img^, PutMode);
- IF DeleteOld THEN BEGIN
- SetActivePage(SourcePage);
- PutImage(x1+j, y1, im.Img^, XorPut);
- END;
- FreeImage(im);
- END;
- SetActivePage(AktPage);
- END;
-
- PROCEDURE Endlos(x1, y1, x2, y2, Step : INTEGER);
- VAR
- i, m : ImageRec;
- j : INTEGER;
- ch : CHAR;
- Quit : BOOLEAN;
- BEGIN
- REPEAT
- CatchImage(x1, y1, x1+Step, y2, m);
- CatchImage(x1+Step, y1, x2, y2, i);
- PutImage(x2-Step, y1, m.Img^, CopyPut);
- PutImage(x1, y1, i.Img^, CopyPut);
- FreeImage(i);
- FreeImage(m);
- Quit := FALSE;
- IF KeyPressed THEN BEGIN
- ch := ReadKey;
- IF ch = #0 THEN BEGIN
- ch := ReadKey;
- CASE ch OF
- #75 : IF Step > 1 THEN Dec(Step);
- #77 : IF Step < (x2-x1-1) THEN Inc(Step);
- END;
- END ELSE
- Quit := TRUE;
- END;
- UNTIL Quit;
- END;
-
- PROCEDURE Invers(x1, y1, x2, y2 : INTEGER);
- VAR
- im : ImageRec;
- BEGIN
- CatchImage(x1, y1, x2, y2, im);
- PutImage(x1, y1, im.Img^, NotPut);
- FreeImage(im);
- END;
-
- BEGIN
- GraphDriver := Detect;
- GraphPath := GetEnv('BGIPATH');
- InitGraph(GraphDriver, GraphMode, GraphPath);
-
- Rectangle(0, 0, GetMaxX, 12);
- OutTextXY(0, 2,
- ' Sinus - Cosinus - Sinus - Cosinus - Sinus - ' +
- 'Cosinus - Sinus - Cosinus - Sinus - Cosinus');
- Invers(0, 0, GetMaxX, 12);
- Endlos(0, 0, GetMaxX, 12, 10);
- Invers(0, 0, GetMaxX, 12);
- CosKurve( 0, 0, GetMaxX, 12, 0, 50, 20, AktPage);
- ReadLn;
- SinKurve(0, 0, GetMaxX, 12, 0, 120, 20, AktPage);
- ReadLn;
- ArcTanKurve(0, 0, GetMaxX, 12, 0, 200, 20, AktPage);
- ReadLn;
- ClearViewPort;
- Rectangle(0, 0, GetMaxX, 12);
- OutTextXY(0, 2, ' Verzerren - Verzerren - Verzerren' +
- ' - Verzerren - Verzerren - Verzerren' +
- ' - Verzerren - ');
- Invers(0, 0, GetMaxX, 12);
- Endlos(0, 0, GetMaxX, 12, 10);
- Invers(0, 0, GetMaxX, 12);
- Verzerre(0, 0, GetMaxX DIV 2, 12, 0, 15, 1, 2, AktPage);
- ReadLn;
- Verzerre(0, 0, GetMaxX DIV 2, 12,
- GetMaxX DIV 2, GetMaxY DIV 2+24,
- -1, 2, AktPage);
- ReadLn;
- Verzerre(0, 0, GetMaxX, 12, 0, 120, 12, 50, AktPage);
- ReadLn;
- Verzerre(0, 0, GetMaxX, 12, 0, 300, -12, 50, AktPage);
- ReadLn;
- CloseGraph;
- END.
- (* ------------------------------------------------------ *)
- (* Ende von VERZERRE.PAS *)