[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gEDA-dev: Arc drawing with libgd NEW PATCH
Try again without the terminal control characters for colour in the diff output!
--
Peter Clifton
Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA
Tel: +44 (0)7729 980173 - (No signal in the lab!)
diff --git a/libgeda/src/o_arc_basic.c b/libgeda/src/o_arc_basic.c
index 2403d3c..6d5f07a 100644
--- a/libgeda/src/o_arc_basic.c
+++ b/libgeda/src/o_arc_basic.c
@@ -1582,46 +1582,27 @@ o_arc_image_write(TOPLEVEL *w_current, O
color = image_black;
}
- start_angle = o_current->arc->start_angle;
- end_angle = o_current->arc->end_angle;
-
- if ( end_angle < 0) {
-
- if (end_angle >= 180) {
- start_angle = (start_angle - (end_angle)) % 360;
- } else {
- start_angle = (start_angle + (end_angle)) % 360;
- }
-
- end_angle = abs(end_angle);
-
- }
-
- end_angle = start_angle + end_angle;
-
-
-
-#if DEBUG
- printf("%d %d -- %d %d -- %d %d\n",
- o_current->arc->screen_x, o_current->arc->screen_y,
- o_current->arc->screen_width-o_current->arc->screen_x,
- o_current->arc->screen_height-o_current->arc->screen_y,
- start_angle, end_angle);
-#endif
-
- if (start_angle < end_angle) {
-
- start_angle = start_angle + 360;
- }
-
-#if DEBUG
- printf("%d %d -- %d %d -- %d %d\n",
- o_current->arc->screen_x, o_current->arc->screen_y,
- o_current->arc->screen_width-o_current->arc->screen_x,
- o_current->arc->screen_height-o_current->arc->screen_y,
- start_angle, end_angle);
-#endif
-
+ // libgd angles are in opposite sense to gschem's internal angles
+ // Also, gschem's "end_angle" is actually the sweep of the arc, not absolute angle
+
+ // Intialise {start|end}_angle to the start of gschem's sweep
+ start_angle = -o_current->arc->start_angle;
+ end_angle = -o_current->arc->start_angle;
+
+ // libgd always sweeps arcs clockwise so we either update
+ // the start_angle, or end_angle as appropriate
+ if ( o_current->arc->end_angle > 0 )
+ start_angle -= o_current->arc->end_angle;
+ else
+ end_angle -= o_current->arc->end_angle;
+
+ // Ensure each angle is within 0-359. Negative angles make libgd blow up.
+ start_angle = ( start_angle < 0 ) ? 360 - ( (-start_angle) % 360 ) : start_angle % 360;
+ end_angle = ( end_angle < 0 ) ? 360 - ( (-end_angle ) % 360 ) : end_angle % 360;
+
+ // libgd docs state that end angle should always be larger than start_angle
+ if (end_angle < start_angle)
+ end_angle += 360;
width = o_current->arc->screen_width;
height = o_current->arc->screen_height;
_______________________________________________
geda-dev mailing list
geda-dev@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev