home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / sonderh1 / circdraw.pas < prev    next >
Pascal/Delphi Source File  |  1987-03-13  |  2KB  |  36 lines

  1. (*-------------------------------------------------------------------------*)
  2. (*                             CIRCDRAW.PAS                                *)
  3. (*         Kreis-"Zeichnen" durch Annaeherung ueber eine Polygon           *)
  4. (*-------------------------------------------------------------------------*)
  5.  
  6. PROCEDURE do_circle (x_center, y_center, radius: INTEGER);
  7.  
  8. CONST two_pi = 6.28318;
  9.       kreis_ecken_faktor = 1;
  10.  
  11. VAR dtheta,                             (* Winkel-Schrittweite             *)
  12.     cosinus_dtheta,                     (* Cosinus der Winkel-Schrittweite *)
  13.     sinus_dtheta    : REAL ;            (* Sinus der Winkel-Schrittweite   *)
  14.     zaehler         : INTEGER;          (* Eckpunktzaehler                 *)
  15.     x, y,                               (* Berechnete Koordinaten          *)
  16.     x_alt           : REAL;             (* x-Koordinate der letzen Ecke    *)
  17.  
  18. BEGIN
  19.   dtheta := two_pi/(kreis_ecken_faktor*radius);
  20.   cosinus_dtheta := Cos(dtheta);
  21.   sinus_dtheta := Sin(dtheta);
  22.   x := 0;
  23.   y := radius;
  24.   movea(Round(x_center + x), Round(y_center + y*Aspect_Ratio));
  25.   FOR zaehler := 1 TO Round(kreis_ecken_faktor*radius) DO
  26.   BEGIN
  27.     x_alt := x;
  28.     x := (x*cosinus_dtheta - y*sinus_dtheta);
  29.     y := (y*cosinus_dtheta + x_alt*sinus_dtheta);
  30.     linea(Round(x_center + x),Round(y_center + y*Aspect_Ratio));
  31.   END;
  32. END;
  33.  
  34. (*-------------------------------------------------------------------------*)
  35. (*                           Ende von CIRCDRAW.PAS                         *)
  36.