home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / CNC11TP.ZIP / CIRCRA.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-01-19  |  1.3 KB  |  42 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.      { CircRA - draw circle using rotation angle method    }
  6.  
  7. var
  8.    ixar,iyar        : word ;    { aspect ratio parameters }
  9.    ar               : single ;  { aspect ratio }
  10.    da,cosda,sinda   : single ;  { step angle and functions }
  11.    ida,nda          : integer ; { loop control }
  12.    t,x,y            : single ;  { coordinate variables }
  13.  
  14. begin
  15.                                 { aspect ratio }
  16.    GetAspectRatio(ixar,iyar) ;
  17.    ar := ixar/iyar ;
  18.                                 { step angle and functions }
  19.    da := 2.0 * sqrt(1.0/r) ;
  20.    nda := Round(2.0 * Pi / da) ;
  21.    if Odd(nda) then Inc(nda) ;
  22.    da := 2.0 * Pi / nda ;
  23.    cosda := cos(da) ;
  24.    sinda := sin(da) ;
  25.                                 { starting point with offset }
  26.    x := r + dr ;
  27.    y := 0.0 ;
  28.    MoveTo(xc+Round(x),yc) ;
  29.                                 { circle }
  30.    for ida := 1 to nda do begin
  31.                                 { rotate coordinates }
  32.       t := x * cosda - y * sinda ;
  33.       y := x * sinda + y * cosda ;
  34.       x := t ;
  35.                                 { apply aspect ratio }
  36.       LineTo(xc+Round(x),yc+Round(y*ar))
  37.  
  38.    end
  39. end ;
  40.  
  41. { Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }
  42.