home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / HISPEED2.LZH / UNITS / EASYGRAF.PAS < prev    next >
Pascal/Delphi Source File  |  1991-07-02  |  2KB  |  107 lines

  1. {$D+}
  2. UNIT EasyGraf;
  3.  
  4. { Filename: EasyGraf.pas      }
  5. { Coder   : Jacob V. Pedersen }
  6. { Coded   : 1-8-1990          }
  7. { Purpose : Example           }
  8.  
  9. { This unit contains code which makes it easy to draw lines ect. }
  10. { It is used by the examples in the \GRAFDEMO directory. }
  11.  
  12.  
  13. INTERFACE
  14. {$F+,D-,R-,S-}
  15.  
  16. Uses GemDecl, GemAES, GemVDI;
  17.  
  18. Var
  19.   ActiveHandle,                 { Handle to graphics screen }
  20.   MaxColor,                     { Max. color index          }
  21.   MinX,                         { Minimum and Maximum       }
  22.   MinY,                         { coordinates               }
  23.   MaxX,
  24.   MaxY         : Integer;
  25.   WorkOut      : WorkOut_array; { Various defaults          }   
  26.  
  27. Procedure InitGraphics;
  28. Procedure DeInitGraphics;
  29. Procedure Line( X1,Y1, X2,Y2 : Integer );
  30. Procedure LineColor( col : Integer );
  31. Procedure ClearDevice;
  32. Procedure SetClipping( X1,Y1,X2,Y2 : Integer );
  33. Procedure Box(x1,y1,x2,y2 : Integer );
  34.  
  35. IMPLEMENTATION
  36. {$F+,D-,R-,S-}
  37.  
  38. Procedure InitGraphics;
  39. Var
  40.   D:      Integer;
  41.   WorkIn: IntIn_array;
  42. Begin
  43.   d:=Appl_Init;
  44.   Activehandle := graf_handle(d,d,d,d);
  45.   For D := 0 to 9 DO
  46.     WorkIn[D] := 1;
  47.   WorkIn[10] := 2;
  48.   WorkIn[11] := 0;
  49.   v_opnvwk(WorkIn,ActiveHandle,WorkOut);  { Open virtual station } 
  50.   MaxX     := WorkOut[0];
  51.   MaxY     := WorkOut[1];
  52.   MaxColor := WorkOut[13]-1;
  53.   MinX := 0;
  54.   MinY := 0;
  55.   SetClipping( MinX, MinY, MaxX, MaxY );
  56. End; { InitGraphics }
  57.  
  58.  
  59. Procedure DeInitGraphics;
  60. Begin
  61.   v_clsvwk(ActiveHandle);             { Close virtual station } 
  62.   Appl_Exit;
  63. End; { DeInitGraphics }
  64.  
  65.  
  66. Procedure SetClipping( X1,Y1,X2,Y2 : Integer );
  67. Var
  68.   Points : Array_4;
  69. Begin
  70.   Points[0] := X1; Points[1] := y1;
  71.   Points[2] := x2; Points[3] := y2;
  72.   vs_clip( ActiveHandle, 1, Points );
  73. End; { SetClipping }
  74.    
  75.  
  76. Procedure ClearDevice;
  77. Begin
  78.  v_clrwk( ActiveHandle );
  79. End; { ClearDevice }
  80.  
  81.  
  82. Procedure LineColor( col : Integer );
  83. Begin
  84.   vsl_color( ActiveHandle, Col );
  85. End; { LineColor }
  86.  
  87.  
  88. Procedure Line( X1,Y1, X2,Y2 : Integer );
  89. Var
  90.   PntArray : PtSin_Array;
  91. Begin
  92.   PntArray[0] := X1; PntArray[1] := Y1; 
  93.   PntArray[2] := X2; PntArray[3] := Y2;
  94.   v_pline( ActiveHandle, 2, PntArray) 
  95. End; { Line }
  96.  
  97.  
  98. Procedure Box(x1,y1,x2,y2 : Integer );
  99. Begin
  100.   Line(x1,y1,x2,y1);
  101.   Line(x2,y1,x2,y2);
  102.   Line(x2,y2,x1,y2);
  103.   Line(x1,y2,x1,y1);
  104. End; { Box }
  105.  
  106. END.
  107.