home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / PASCAL / MISCTI10.ZIP / TI424.ASC < prev    next >
Encoding:
Text File  |  1988-05-02  |  1.8 KB  |  56 lines

  1. {****************************************************************
  2. The  .BGI files  supplied with  the Graph  unit declare an Aspect
  3. Ratio constant  which is used  to draw circles  and arc segments.
  4. For some applications it is  necessary to alter the aspect ratio.
  5. One such application results when trying to perform a screen dump
  6. to the  printer. In quad-density graphics  printing, it is useful
  7. to redefine the  aspect ratio so the  displayed results will be
  8. circular instead of ellipsoid.
  9.  
  10. The following program demonstrates how a programmer can alter the
  11. predefined  Xasp element  of the  aspect ratio  and to obtain the
  12. current  value.  Note  that  the   Graph  unit  already  has  the
  13. procedure for GetAspectRatio.
  14. ****************************************************************}
  15.  
  16. program ChangeAspectRatio;
  17.  
  18. uses
  19.   Crt, Graph;
  20.  
  21. function GetAspectX : word;
  22. { Return the current aspect ratio element Xasp }
  23. begin
  24.   GetAspectX := word(Ptr(Seg(GraphFreeMemPtr),
  25.                      Ofs(GraphFreeMemPtr)+277)^);
  26. end;
  27.  
  28. procedure SetAspectRatio(NewAspect : word);
  29. { Set the current aspect ratio element Xasp }
  30. begin
  31.   word(Ptr(Seg(GraphFreeMemPtr),
  32.            Ofs(GraphFreeMemPtr)+277)^) := NewAspect;
  33. end;
  34.  
  35. var
  36.   GraphDriver, GraphMode : integer;
  37.   Ch : char;
  38.   S : String;
  39. begin
  40.   DirectVideo := false;
  41.   GraphDriver := Detect;
  42.   InitGraph(GraphDriver, GraphMode, '');
  43.   Str(GetAspectX, S);
  44.   S := 'The initial aspect ratio was ' + S;
  45.   OutTextXY(1,1, S);
  46.   Circle((GetMaxX Div 2), (GetMaxY Div 4), (GetMaxY div 4));
  47.   SetAspectRatio(5000);
  48.   Circle((GetMaxX Div 2), 3*(GetMaxY Div 4), (GetMaxY div 4));
  49.   Str(GetAspectX, S);
  50.   S := 'Now the aspect ratio is ' + S;
  51.   OutTextXY(1,(GetMaxY - 10), S);
  52.   Ch := ReadKey;
  53.   CloseGraph;
  54. end.
  55.  
  56.