home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / CNC11TP.ZIP / CIRCRAI2.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-01-19  |  1.9 KB  |  50 lines

  1. { Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }
  2.  
  3. procedure StrokeCircle ( xc, yc : integer ; r : word ) ;
  4.  
  5.      { CircRAI2 - draw circle using rotation angle method, }
  6.      {            `increment' angle step, and semi-        }
  7.      {            circular symmetry                        }
  8.  
  9. var
  10.    ixar,iyar        : word ;    { aspect ratio variables }
  11.    iar              : longint ; { aspect ratio B16 }
  12.    ida              : integer ; { loop control }
  13.    it,ix,iy         : longint ; { coordinate variables B6 }
  14.    ix0,iy0,ix1,iy1  : integer ; { display coordinates B0 }
  15.  
  16. begin
  17.                                 { constraint test }
  18.    if r < 511 then begin
  19.                                 { aspect ratio }
  20.       GetAspectRatio(ixar,iyar) ;
  21.       iar := SwapLong(longint(ixar)) div longint(iyar) ;
  22.                                 { prescale and offset }
  23.       ix := r shl 6 + idr ;
  24.       iy := 0 ;
  25.                                 { starting point }
  26.       ix0 := RoundScaleB6(ix) ;
  27.       iy0 := iy ;
  28.                                 { circle }
  29.       for ida := 1 to 50 do begin
  30.                                 { rotate coordinates }
  31.          it := RoundScaleB16(((((ix shl 4 - iy) shl 5 -
  32.                ix) shl 3 - iy) shl 2 - iy) shl 2) ;
  33.          iy := RoundScaleB16(((((iy shl 4 + ix) shl 5 -
  34.                iy) shl 3 + ix) shl 2 + ix) shl 2) ;
  35.          ix := it ;
  36.                                 { apply aspect and scale B0 }
  37.          ix1 := RoundScaleB6(ix) ;
  38.          iy1 := RoundScaleB6(LongHi(iy * iar)) ;
  39.                                 { semi-circular symmetry }
  40.          Line(xc+ix0,yc+iy0,xc+ix1,yc+iy1) ;
  41.          Line(xc-ix0,yc-iy0,xc-ix1,yc-iy1) ;
  42.                                 { ladder down }
  43.          ix0 := ix1 ;  iy0 := iy1
  44.  
  45.       end
  46.    end
  47. end ;
  48.  
  49. { Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }
  50.