home *** CD-ROM | disk | FTP | other *** search
- (*-------------------------------------------------------------------------*)
- (* CIRCDRAW.PAS *)
- (* Kreis-"Zeichnen" durch Annaeherung ueber eine Polygon *)
- (*-------------------------------------------------------------------------*)
-
- PROCEDURE do_circle (x_center, y_center, radius: INTEGER);
-
- CONST two_pi = 6.28318;
- kreis_ecken_faktor = 1;
-
- VAR dtheta, (* Winkel-Schrittweite *)
- cosinus_dtheta, (* Cosinus der Winkel-Schrittweite *)
- sinus_dtheta : REAL ; (* Sinus der Winkel-Schrittweite *)
- zaehler : INTEGER; (* Eckpunktzaehler *)
- x, y, (* Berechnete Koordinaten *)
- x_alt : REAL; (* x-Koordinate der letzen Ecke *)
-
- BEGIN
- dtheta := two_pi/(kreis_ecken_faktor*radius);
- cosinus_dtheta := Cos(dtheta);
- sinus_dtheta := Sin(dtheta);
- x := 0;
- y := radius;
- movea(Round(x_center + x), Round(y_center + y*Aspect_Ratio));
- FOR zaehler := 1 TO Round(kreis_ecken_faktor*radius) DO
- BEGIN
- x_alt := x;
- x := (x*cosinus_dtheta - y*sinus_dtheta);
- y := (y*cosinus_dtheta + x_alt*sinus_dtheta);
- linea(Round(x_center + x),Round(y_center + y*Aspect_Ratio));
- END;
- END;
-
- (*-------------------------------------------------------------------------*)
- (* Ende von CIRCDRAW.PAS *)