home *** CD-ROM | disk | FTP | other *** search
- { Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }
-
- procedure StrokePolygon ( xc, yc : integer ; { center }
- r, n : word ; { radius and number of sides }
- ta : single ) ; { rotation angle (rad) }
-
- { PolyRA - draw regular polygon using rotation angle }
- { method and floating point arithemtic }
-
- var
- ixar,iyar : word ; { aspect ratio parameters }
- ar : single ; { aspect ratio }
- da,cosda,sinda : single ; { step angle and functions }
- i : integer ; { loop control }
- t,x,y : single ; { coordinate variables }
-
- begin
- { constraint test }
- if (r > 0) and (n > 2) then begin
- { aspect ratio }
- GetAspectRatio(ixar,iyar) ;
- ar := ixar/iyar ;
- { step angle and functions }
- da := 2.0 * Pi / n ;
- cosda := cos(da) ;
- sinda := sin(da) ;
- { starting point with offset }
- x := r * cos(ta) ;
- y := -r * sin(ta) ;
- MoveTo(xc+Round(x),yc+Round(y*ar)) ;
- { polygon }
- for i := 1 to n do begin
- { rotate coordinates }
- t := x * cosda - y * sinda ;
- y := x * sinda + y * cosda ;
- x := t ;
- { apply aspect ratio }
- LineTo(xc+Round(x),yc+Round(y*ar))
-
- end
- end
- end ;
-
- { Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }