Author: spouliot
Date: 2007-06-04 19:29:59 -0400 (Mon, 04 Jun 2007)
New Revision: 78602

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/shape.cpp
   trunk/moon/src/shape.h
Log:
2007-06-04  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * shape.cpp|h: Add Poly[line|gon] drawing code and C helper functions 
        to create them. Replace the "old" C1 constant in Ellipse::Draw with 
        ARC_TO_BEZIER (now that I know where it comes from ;-)



Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-06-04 22:58:47 UTC (rev 78601)
+++ trunk/moon/src/ChangeLog    2007-06-04 23:29:59 UTC (rev 78602)
@@ -1,3 +1,9 @@
+2007-06-04  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * shape.cpp|h: Add Poly[line|gon] drawing code and C helper functions 
+       to create them. Replace the "old" C1 constant in Ellipse::Draw with 
+       ARC_TO_BEZIER (now that I know where it comes from ;-)
+
 2007-06-04  Jeffrey Stedfast  <[EMAIL PROTECTED]>
 
        * ffvideo.cpp (queue_data): Got sound kinda sorta working...

Modified: trunk/moon/src/shape.cpp
===================================================================
--- trunk/moon/src/shape.cpp    2007-06-04 22:58:47 UTC (rev 78601)
+++ trunk/moon/src/shape.cpp    2007-06-04 23:29:59 UTC (rev 78602)
@@ -175,9 +175,6 @@
 void
 Ellipse::Draw (Surface *s)
 {
-
-#define C1 0.552285
-
        double rx, ry, cx, cy;
 
        rx = w / 2;
@@ -190,23 +187,23 @@
        /* an approximate of the ellipse by drawing a curve in each
         * quadrants */
        cairo_curve_to (s->cairo,
-                       cx + rx, cy - C1 * ry,
-                       cx + C1 * rx, cy - ry,
+                       cx + rx, cy - ARC_TO_BEZIER * ry,
+                       cx + ARC_TO_BEZIER * rx, cy - ry,
                        cx, cy - ry);
         
        cairo_curve_to (s->cairo,
-                       cx - C1 * rx, cy - ry,
-                       cx - rx, cy - C1 * ry,
+                       cx - ARC_TO_BEZIER * rx, cy - ry,
+                       cx - rx, cy - ARC_TO_BEZIER * ry,
                        cx - rx, cy);
 
        cairo_curve_to (s->cairo,
-                       cx - rx, cy + C1 * ry,
-                       cx - C1 * rx, cy + ry,
+                       cx - rx, cy + ARC_TO_BEZIER * ry,
+                       cx - ARC_TO_BEZIER * rx, cy + ry,
                        cx, cy + ry);
                 
        cairo_curve_to (s->cairo,
-                       cx + C1 * rx, cy + ry,
-                       cx + rx, cy + C1 * ry,
+                       cx + ARC_TO_BEZIER * rx, cy + ry,
+                       cx + rx, cy + ARC_TO_BEZIER * ry,
                        cx + rx, cy);
 
        cairo_close_path (s->cairo);
@@ -306,6 +303,23 @@
 void
 Polygon::Draw (Surface *s)
 {
+       int i;
+
+       if (!points || (count < 1))
+               return;
+
+       cairo_move_to (s->cairo, points [0].x, points [0].y);
+
+       for (i = 1; i < count; i++) {
+               cairo_line_to (s->cairo, points [i].x, points [i].y);
+       }
+
+       // Draw a line from the last point back to the first point if they're 
not the same
+       if ((points [0].x != points [count-1].x) && (points [0].y != points 
[count-1].y)) {
+               cairo_line_to (s->cairo, points [0].x, points [0].y);
+       }
+
+       cairo_close_path (s->cairo);
 }
 
 void
@@ -322,9 +336,26 @@
        polygon->count = count;
 }
 
+Polygon *
+polygon_new ()
+{
+       return new Polygon ();
+}
+
+
 void
 Polyline::Draw (Surface *s)
 {
+       int i;
+
+       if (!points || (count < 1))
+               return;
+
+       cairo_move_to (s->cairo, points [0].x, points [0].y);
+
+       for (i = 1; i < count; i++) {
+               cairo_line_to (s->cairo, points [i].x, points [i].y);
+       }
 }
 
 void
@@ -340,3 +371,9 @@
        polyline->points = points;
        polyline->count = count;
 }
+
+Polyline *
+polyline_new ()
+{
+       return new Polyline ();
+}

Modified: trunk/moon/src/shape.h
===================================================================
--- trunk/moon/src/shape.h      2007-06-04 22:58:47 UTC (rev 78601)
+++ trunk/moon/src/shape.h      2007-06-04 23:29:59 UTC (rev 78602)
@@ -122,6 +122,7 @@
 
        void Draw (Surface *s);
 };
+Polygon *polygon_new ();
 void polygon_set_fill_rule (Polygon *polygon, FillRule fill_rule);
 void polygon_set_points (Polygon *polygon, Point* points, int count);
 
@@ -138,6 +139,7 @@
 
        void Draw (Surface *s);
 };
+Polyline *polyline_new ();
 void polyline_set_fill_rule (Polyline *polyline, FillRule fill_rule);
 void polyline_set_points (Polyline *polyline, Point* points, int count);
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to