summaryrefslogtreecommitdiff
path: root/src/intcgm/circle.c
diff options
context:
space:
mode:
authorscuri <scuri>2008-10-17 06:10:33 +0000
committerscuri <scuri>2008-10-17 06:10:33 +0000
commit7b52cc13af4e85f1ca2deb6b6c77de9c95ea0dcf (patch)
treed0857278bde2eff784227c57dcaf930346ceb7ac /src/intcgm/circle.c
First commit - moving from LuaForge to SourceForge
Diffstat (limited to 'src/intcgm/circle.c')
-rw-r--r--src/intcgm/circle.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/intcgm/circle.c b/src/intcgm/circle.c
new file mode 100644
index 0000000..4f54fed
--- /dev/null
+++ b/src/intcgm/circle.c
@@ -0,0 +1,100 @@
+#include <stdio.h>
+#include <math.h>
+
+#include <cd.h>
+
+#include "list.h"
+#include "types.h"
+#include "intcgm.h"
+#include "intcgm6.h"
+
+#include "circle.h"
+
+#define DIM 360
+
+#ifndef PI
+#define PI 3.14159265358979323846
+#endif
+
+#define PI180 PI/180.
+#define TWOPI 2*PI
+#define VARCS TWOPI/32.
+
+int cgm_poly_circle ( double xc, double yc, double radius, double angi, double angf, int fechado )
+{
+ double coseno, seno;
+ double xs, ys;
+
+ coseno = cos (VARCS);
+ seno = sin (VARCS);
+
+ xs = radius * cos(angi);
+ ys = radius * sin(angi);
+
+ cdCanvasBegin(intcgm_canvas, cgm_setintstyle(intcgm_fill_att.int_style) );
+
+ if ( fechado==CLOSED_PIE ) cdCanvasVertex (intcgm_canvas, cgm_vdcx2canvas(xc), cgm_vdcy2canvas(yc) );
+
+ cdCanvasVertex (intcgm_canvas, cgm_vdcx2canvas(xc+xs), cgm_vdcy2canvas(yc+ys) );
+
+ while ( (angi+VARCS) < angf )
+ {
+ double xe = xs;
+ xs = xs * coseno - ys * seno;
+ ys = ys * coseno + xe * seno;
+ cdCanvasVertex (intcgm_canvas, cgm_vdcx2canvas(xc+xs), cgm_vdcy2canvas(yc+ys) );
+ angi += VARCS;
+ }
+
+ cdCanvasVertex (intcgm_canvas, cgm_vdcx2canvas(xc+radius*cos(angf)), cgm_vdcy2canvas(yc+radius*sin(angf)) );
+
+ cdCanvasEnd(intcgm_canvas);
+
+ return 0;
+}
+
+int cgm_line_circle ( double xc, double yc, double radius, double angi, double angf, int fechado )
+{
+ double coseno, seno;
+ double xant, yant, firstx, firsty;
+ double xs, ys;
+
+ /* GERA O DESENHO DO CIRCULO/ARCO */
+
+ coseno = cos (VARCS);
+ seno = sin (VARCS);
+
+ xs = radius * cos(angi);
+ ys = radius * sin(angi);
+
+ if ( fechado==CLOSED_PIE )
+ cdCanvasLine (intcgm_canvas, cgm_vdcx2canvas(xc), cgm_vdcy2canvas(yc), cgm_vdcx2canvas(xc+xs), cgm_vdcy2canvas(yc+ys) );
+
+ xant = firstx = xc+xs;
+ yant = firsty = yc+ys;
+
+ while ( (angi+VARCS) < angf )
+ {
+ double xe = xs;
+ xs = xs * coseno - ys * seno;
+ ys = ys * coseno + xe * seno;
+ cdCanvasLine (intcgm_canvas, cgm_vdcx2canvas(xant), cgm_vdcy2canvas(yant), cgm_vdcx2canvas(xc+xs), cgm_vdcy2canvas(yc+ys) );
+ xant = xc+xs;
+ yant = yc+ys;
+ angi += VARCS;
+ }
+
+ cdCanvasLine (intcgm_canvas, cgm_vdcx2canvas(xant), cgm_vdcy2canvas(yant),
+ cgm_vdcx2canvas(xc+radius*cos(angf)), cgm_vdcy2canvas(yc+radius*sin(angf)) );
+
+ xant = xc+radius*cos(angf);
+ yant = yc+radius*sin(angf);
+
+ if ( fechado==CLOSED_PIE )
+ cdCanvasLine (intcgm_canvas, cgm_vdcx2canvas(xant), cgm_vdcy2canvas(yant), cgm_vdcx2canvas(xc), cgm_vdcy2canvas(yc) );
+ else if ( fechado==CLOSED_CHORD )
+ cdCanvasLine (intcgm_canvas, cgm_vdcx2canvas(xant), cgm_vdcy2canvas(yant), cgm_vdcx2canvas(firstx), cgm_vdcy2canvas(firsty) );
+
+ return 0;
+}
+