Author: duncan
Date: 2005-05-24 00:24:04 -0400 (Tue, 24 May 2005)
New Revision: 44923
Modified:
trunk/libgdiplus/src/ChangeLog
trunk/libgdiplus/src/graphics-path.c
trunk/libgdiplus/src/graphics.c
Log:
2005-05-24 Duncan Mak <[EMAIL PROTECTED]>
* graphics-path.c (append_arc): Append PathPointTypeLine instead
of PathPointTypeStart, so that arcs will be joint properly. This
fixes bug #75015. Thanks to Elliot Paquette for reporting and
fixing this bug.
2005-05-24 Duncan Mak <[EMAIL PROTECTED]>
* graphics.c (make_pie, GdipDrawArc):
* graphics-path.cs (GdipAddPathArc, GdipAddPathPie): Rewrote the
code for calculating arcs: instead of drawing two arcs via a
mid-point, draw multiple arcs at intervals of 90 degrees. This
results in prettier arcs/pies and a better match to the output
produced by MS.
Modified: trunk/libgdiplus/src/ChangeLog
===================================================================
--- trunk/libgdiplus/src/ChangeLog 2005-05-24 00:28:53 UTC (rev 44922)
+++ trunk/libgdiplus/src/ChangeLog 2005-05-24 04:24:04 UTC (rev 44923)
@@ -1,3 +1,19 @@
+2005-05-24 Duncan Mak <[EMAIL PROTECTED]>
+
+ * graphics-path.c (append_arc): Append PathPointTypeLine instead
+ of PathPointTypeStart, so that arcs will be joint properly. This
+ fixes bug #75015. Thanks to Elliot Paquette for reporting and
+ fixing this bug.
+
+2005-05-24 Duncan Mak <[EMAIL PROTECTED]>
+
+ * graphics.c (make_pie, GdipDrawArc):
+ * graphics-path.cs (GdipAddPathArc, GdipAddPathPie): Rewrote the
+ code for calculating arcs: instead of drawing two arcs via a
+ mid-point, draw multiple arcs at intervals of 90 degrees. This
+ results in prettier arcs/pies and a better match to the output
+ produced by MS.
+
2005-05-20 Duncan Mak <[EMAIL PROTECTED]>
* graphics-path.c (GdipAddPathArc): Added a special case for
Modified: trunk/libgdiplus/src/graphics-path.c
===================================================================
--- trunk/libgdiplus/src/graphics-path.c 2005-05-24 00:28:53 UTC (rev
44922)
+++ trunk/libgdiplus/src/graphics-path.c 2005-05-24 04:24:04 UTC (rev
44923)
@@ -575,7 +575,7 @@
/* move to the starting point if we're not continuing a curve */
if (start)
- append (path, sx, sy, PathPointTypeStart);
+ append (path, sx, sy, PathPointTypeLine);
append_bezier (path,
cx + rx * (cos_alpha - bcp * sin_alpha),
@@ -590,19 +590,23 @@
GdipAddPathArc (GpPath *path, float x, float y,
float width, float height, float startAngle, float sweepAngle)
{
- float endAngle = startAngle + sweepAngle;
+ float endAngle = startAngle + sweepAngle;
+ int i, sign = (endAngle > 0) ? 1 : -1;
+
g_return_val_if_fail (path != NULL, InvalidParameter);
if (abs (sweepAngle) >= 360)
return GdipAddPathEllipse (path, x, y, width, height);
- if (abs (sweepAngle) < 180)
- append_arc (path, TRUE, x, y, width, height, startAngle,
endAngle);
- else {
- float midAngle = startAngle + (sweepAngle / 2.0);
- append_arc (path, TRUE, x, y, width, height, startAngle,
midAngle);
- append_arc (path, FALSE, x, y, width, height, midAngle,
endAngle);
- }
+ /* draw the arcs */
+ for (i = 0; i < abs (endAngle); i += 90) {
+ append_arc (path,
+ (i == 0) ? TRUE : FALSE, /* only move to the
starting pt in the 1st iteration */
+ x, y, width, height, /* bounding rectangle */
+ i * sign, /* start angle */
+ (i + 90 < abs (endAngle)) ? (i + 90) * sign :
endAngle); /* sweep angle,
+
at most up to 90 degrees */
+ }
return Ok;
}
@@ -775,6 +779,8 @@
float endAngle = startAngle + sweepAngle;
+ int i, sign = (endAngle > 0) ? 1 : -1;
+
/* angles in radians */
float alpha = startAngle * PI / 180;
@@ -785,7 +791,6 @@
/* move to center */
append (path, cx, cy, PathPointTypeStart);
-
/* draw pie edge */
append (path, cx + rx * cos_alpha, cy + ry * sin_alpha,
@@ -794,14 +799,16 @@
/* draw arc */
if (abs (sweepAngle) >= 360)
return GdipAddPathEllipse (path, x, y, width, height);
- if (abs (sweepAngle) < 180)
- append_arc (path, TRUE, x, y, width, height, startAngle,
endAngle);
- else {
- float midAngle = startAngle + (sweepAngle / 2.0);
- append_arc (path, TRUE, x, y, width, height, startAngle,
midAngle);
- append_arc (path, FALSE, x, y, width, height, midAngle,
endAngle);
- }
+ /* draw the arcs */
+ for (i = 0; i < abs (endAngle); i += 90) {
+ append_arc (path,
+ (i == 0) ? TRUE : FALSE, /* only move to the
starting pt in the 1st iteration */
+ x, y, width, height, /* bounding rectangle */
+ i * sign, /* start angle */
+ (i + 90 < abs (endAngle)) ? (i + 90) * sign :
endAngle); /* sweep angle,
+
at most up to 90 degrees */
+ }
/* draw pie edge */
append (path, cx, cy, PathPointTypeLine);
Modified: trunk/libgdiplus/src/graphics.c
===================================================================
--- trunk/libgdiplus/src/graphics.c 2005-05-24 00:28:53 UTC (rev 44922)
+++ trunk/libgdiplus/src/graphics.c 2005-05-24 04:24:04 UTC (rev 44923)
@@ -232,6 +232,8 @@
float endAngle = startAngle + sweepAngle;
+ int i, sign = (endAngle > 0) ? 1 : -1;
+
/* angles in radians */
float alpha = startAngle * PI / 180;
@@ -252,19 +254,16 @@
return;
}
- /*
- * draw the arc, if the sweep is bigger than 180, draw it
- * twice, using a middle angle.
- */
- if (abs (sweepAngle) < 180)
- make_arc (graphics, TRUE, x, y, width, height, startAngle,
endAngle);
- else {
- float midAngle = startAngle + (sweepAngle / 2.0);
+ /* draw the arcs */
+ for (i = 0; i < abs (endAngle); i += 90) {
+ make_arc (graphics,
+ (i == 0) ? TRUE : FALSE, /* only move to the
starting pt in the 1st iteration */
+ x, y, width, height, /* bounding rectangle */
+ i * sign, /* start angle */
+ (i + 90 < abs (endAngle)) ? (i + 90) * sign :
endAngle); /* sweep angle,
+
at most up to 90 degrees */
+ }
- make_arc (graphics, TRUE, x, y, width, height, startAngle,
midAngle);
- make_arc (graphics, FALSE, x, y, width, height, midAngle,
endAngle);
- }
-
/* draws line back to center */
cairo_line_to (graphics->ct, cx, cy);
}
@@ -558,17 +557,20 @@
/* just make an ellipse if we're going a full 360 degrees */
if (abs (sweepAngle) >= 360)
make_ellipse (graphics, x, y, width, height);
+ else {
+ int i, sign = (endAngle > 0) ? 1 : -1;
- else if (abs (sweepAngle) < 180)
- make_arc (graphics, TRUE, x, y, width, height, startAngle,
endAngle);
+ /* draw the arcs */
+ for (i = 0; i < abs (endAngle); i += 90) {
+ make_arc (graphics,
+ (i == 0) ? TRUE : FALSE, /* only move to
the starting pt in the 1st iteration */
+ x, y, width, height, /* bounding
rectangle */
+ i * sign, /* start angle */
+ (i + 90 < abs (endAngle)) ? (i + 90) * sign :
endAngle); /* sweep angle,
+
at most up to 90 degrees */
+ }
+ }
- else {
- float midAngle = startAngle + (sweepAngle / 2.0);
-
- make_arc (graphics, TRUE, x, y, width, height, startAngle,
midAngle);
- make_arc (graphics, FALSE, x, y, width, height, midAngle,
endAngle);
- }
-
/* We do pen setup just before stroking. */
gdip_pen_setup (graphics, pen);
cairo_stroke (graphics->ct);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches