[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: CVS update: o_arc_basic.c
User: ahvezda
Date: 07/01/16 19:08:54
Modified: . o_arc_basic.c
Log:
Applied patch by Peter Clifton to fix the output of arcs when using libgd.
Revision Changes Path
1.32 +20 -39 eda/geda/gaf/libgeda/src/o_arc_basic.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: o_arc_basic.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_arc_basic.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- o_arc_basic.c 7 Dec 2006 04:24:18 -0000 1.31
+++ o_arc_basic.c 17 Jan 2007 00:08:53 -0000 1.32
@@ -1582,46 +1582,27 @@
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-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs