Author: jackson
Date: 2007-06-04 15:07:24 -0400 (Mon, 04 Jun 2007)
New Revision: 78581
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/shape.cpp
trunk/moon/src/shape.h
Log:
- set width/height on ellipse's (ellipsi ?) and draw
them.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-06-04 18:49:52 UTC (rev 78580)
+++ trunk/moon/src/ChangeLog 2007-06-04 19:07:24 UTC (rev 78581)
@@ -1,6 +1,7 @@
2007-06-04 Jackson Harper <[EMAIL PROTECTED]>
* shape.cpp/h: add ellipse_new
+ - set width/height on ellipse's (ellipsi ?) and draw them.
2007-06-04 Jackson Harper <[EMAIL PROTECTED]>
Modified: trunk/moon/src/shape.cpp
===================================================================
--- trunk/moon/src/shape.cpp 2007-06-04 18:49:52 UTC (rev 78580)
+++ trunk/moon/src/shape.cpp 2007-06-04 19:07:24 UTC (rev 78581)
@@ -175,7 +175,41 @@
void
Ellipse::Draw (Surface *s)
{
- // TODO
+
+#define C1 0.552285
+
+ double rx, ry, cx, cy;
+
+ rx = width / 2;
+ ry = height / 2;
+ cx = x + rx;
+ cy = y + ry;
+
+ cairo_move_to (s->cairo, cx + rx, cy);
+
+ /* 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, cy - ry);
+
+ cairo_curve_to (s->cairo,
+ cx - C1 * rx, cy - ry,
+ cx - rx, cy - C1 * ry,
+ cx - rx, cy);
+
+ cairo_curve_to (s->cairo,
+ cx - rx, cy + C1 * ry,
+ cx - C1 * rx, cy + ry,
+ cx, cy + ry);
+
+ cairo_curve_to (s->cairo,
+ cx + C1 * rx, cy + ry,
+ cx + rx, cy + C1 * ry,
+ cx + rx, cy);
+
+ cairo_close_path (s->cairo);
}
Ellipse *
@@ -185,6 +219,17 @@
}
void
+Ellipse::set_prop_from_str (const char *prop, const char *value)
+{
+ if (!g_strcasecmp (prop, "width"))
+ width = strtod (value, NULL);
+ else if (!g_strcasecmp (prop, "height"))
+ height = strtod (value, NULL);
+ else
+ Shape::set_prop_from_str (prop, value);
+}
+
+void
Rectangle::Draw (Surface *s)
{
// static int n;
Modified: trunk/moon/src/shape.h
===================================================================
--- trunk/moon/src/shape.h 2007-06-04 18:49:52 UTC (rev 78580)
+++ trunk/moon/src/shape.h 2007-06-04 19:07:24 UTC (rev 78581)
@@ -65,9 +65,13 @@
//
class Ellipse : public Shape {
public:
- Ellipse () {};
+ double width, height;
+ Ellipse () : width (0), height (0) { };
+
void Draw (Surface *s);
+
+ virtual void set_prop_from_str (const char *prop, const char *value);
};
Ellipse *ellipse_new ();
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches