Technical Information Database TI53D.txt - Modifying the aspect ratio in the graph unit Category :Turbo Pascal Platform :All Product : Description: {**************************************************************** The .BGI files supplied with the Graph unit declare an Aspect Ratio constant which is used to draw circles and arc segments. For some applications it is necessary to alter the aspect ratio. One such application results when trying to perform a screen dump to the printer. In quad-density graphics printing, it is useful to redefine the aspect ratio so the displayed results will be circular instead of ellipsoid. The following program demonstrates how a programmer can alter the predefined Xasp element of the aspect ratio and to obtain the current value. Note that the Graph unit already has the procedure for GetAspectRatio. ****************************************************************} program ChangeAspectRatio; uses Crt, Graph; function GetAspectX : word; { Return the current aspect ratio element Xasp } begin GetAspectX := word(Ptr(Seg(GraphFreeMemPtr), Ofs(GraphFreeMemPtr)+277)^); end; procedure SetAspectRatio(NewAspect : word); { Set the current aspect ratio element Xasp } begin word(Ptr(Seg(GraphFreeMemPtr), Ofs(GraphFreeMemPtr)+277)^) := NewAspect; end; var GraphDriver, GraphMode : integer; Ch : char; S : String; begin DirectVideo := false; GraphDriver := Detect; InitGraph(GraphDriver, GraphMode, ''); Str(GetAspectX, S); S := 'The initial aspect ratio was ' + S; OutTextXY(1,1, S); Circle((GetMaxX Div 2), (GetMaxY Div 4), (GetMaxY div 4)); SetAspectRatio(5000); Circle((GetMaxX Div 2), 3*(GetMaxY Div 4), (GetMaxY div 4)); Str(GetAspectX, S); S := 'Now the aspect ratio is ' + S; OutTextXY(1,(GetMaxY - 10), S); Ch := ReadKey; CloseGraph; end. Reference: 3/30/99 3:08:48 PM
Last Modified: 01-SEP-99