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

  1. { Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }
  2.  
  3. procedure StrokeEllipse ( xc, yc : integer ; { center }
  4.                             a, b : word ; { radii }
  5.                               ta : single ) ; { rotation angle (rad) }
  6.  
  7.      { ElipRAM - draw ellipse using rotation angle method  }
  8.      {           and `minimum' angle step                  }
  9.  
  10. var
  11.    ixar,iyar        : word ;    { aspect ratio parameters }
  12.    iar              : longint ; { aspect ratio B16 }
  13.    icosta,isinta    : longint ; { rotation angle functions B16 }
  14.    ira,irb          : longint ; { offset radii B6 }
  15.    ida              : integer ; { loop control }
  16.    it,ixa,iya       : longint ; { coordinate variables B6 }
  17.    ixb,iyb          : longint ; { coordinate variables B6 }
  18.    ix0,iy0          : integer ; { display coordinates B0 }
  19.  
  20. begin
  21.                                 { constraint test }
  22.    if (a < 511) and (b < 511) then begin
  23.                                 { aspect ratio }
  24.       GetAspectRatio(ixar,iyar) ;
  25.       iar := SwapLong(longint(ixar)) div longint(iyar) ;
  26.                                 { offset, rotation, prescale, }
  27.                                 { aspect and reflection       }
  28.       icosta := Round(cos(ta) * 65536) ;
  29.       isinta := Round(sin(ta) * 65536) ;
  30.  
  31.       ira := a shl 6 + idr ;
  32.       irb := b shl 6 + idr ;
  33.  
  34.       ixa := RoundScaleB16(ira * icosta) ;
  35.       iya := -RoundScaleB16(irb * isinta) ;
  36.  
  37.       ixb := RoundScaleB16(RoundScaleB16(irb * icosta) * iar) ;
  38.       iyb := -RoundScaleB16(RoundScaleB16(ira * isinta) * iar) ;
  39.                                 { starting point }
  40.       ix0 := RoundScaleB6(ixa) ;
  41.       iy0 := RoundScaleB6(iyb) ;
  42.       MoveTo(xc+ix0,yc+iy0) ;
  43.                                 { ellipse }
  44.       for ida := 1 to 49 do begin
  45.                                 { rotate coordinates }
  46.          it := ((ixa shl 3 - iya) shl 4 - ixa) div 128 ;
  47.          iya := ((iya shl 3 + ixa) shl 4 - iya) div 128 ;
  48.          ixa := it ;
  49.  
  50.          it := ((ixb shl 3 - iyb) shl 4 - ixb) div 128 ;
  51.          iyb := ((iyb shl 3 + ixb) shl 4 - iyb) div 128 ;
  52.          ixb := it ;
  53.                                 { draw stroke }
  54.          LineTo(xc+RoundScaleB6(ixa),yc+RoundScaleB6(iyb))
  55.  
  56.       end ;
  57.                                 { closure }
  58.       LineTo(xc+ix0,yc+iy0)
  59.  
  60.    end
  61. end ;
  62.  
  63. { Copyright (C) 1989 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }
  64.