Hi all,
Turns out that the previous patch I produced didn't work with arcs which
had a -ve swept angle - thanks Ales for discovering that.
I've re-done this one (and added some comments, as it isn't immediately
obvious why the code is as it is. We have libgd to thank there!
This _should_ work for any +/- start angle, and +/- sweep angle. Sweep
angles of magnitude greater than +/-360 may produce an odd effect
though, but that is really bogus data, and gschem probably won't allow
it to ever happen.
Ales - please give this patch a try! I had some time to think about how
it should be done more correctly, and this is what I came up with.
--
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!)
[1;36mdiff --git a/libgeda/src/o_arc_basic.c b/libgeda/src/o_arc_basic.c[0m
index 2403d3c..6d5f07a 100644
[1;31m--- a/libgeda/src/o_arc_basic.c[0m
[1;32m+++ b/libgeda/src/o_arc_basic.c[0m
[36m@@ -1582,46 +1582,27 @@[0m [34mo_arc_image_write(TOPLEVEL *w_current, O[0m
color = image_black;
}
[31m- start_angle = o_current->arc->start_angle;[0m
[31m- end_angle = o_current->arc->end_angle;[0m
[31m-[0m
[31m- if ( end_angle < 0) {[0m
[31m-[0m
[31m- if (end_angle >= 180) {[0m
[31m- start_angle = (start_angle - (end_angle)) % 360;[0m
[31m- } else {[0m
[31m- start_angle = (start_angle + (end_angle)) % 360;[0m
[31m- }[0m
[31m-[0m
[31m- end_angle = abs(end_angle);[0m
[31m-[0m
[31m- }[0m
[31m-[0m
[31m- end_angle = start_angle + end_angle;[0m
[31m-[0m
[31m-[0m
[31m-[0m
[31m-#if DEBUG[0m
[31m- printf("%d %d -- %d %d -- %d %d\n", [0m
[31m- o_current->arc->screen_x, o_current->arc->screen_y,[0m
[31m- o_current->arc->screen_width-o_current->arc->screen_x,[0m
[31m- o_current->arc->screen_height-o_current->arc->screen_y,[0m
[31m- start_angle, end_angle);[0m
[31m-#endif[0m
[31m-[0m
[31m- if (start_angle < end_angle) {[0m
[31m-[0m
[31m- start_angle = start_angle + 360;[0m
[31m- }[0m
[31m-[0m
[31m-#if DEBUG[0m
[31m- printf("%d %d -- %d %d -- %d %d\n", [0m
[31m- o_current->arc->screen_x, o_current->arc->screen_y,[0m
[31m- o_current->arc->screen_width-o_current->arc->screen_x,[0m
[31m- o_current->arc->screen_height-o_current->arc->screen_y,[0m
[31m- start_angle, end_angle);[0m
[31m-#endif[0m
[31m-[0m
[32m+ // libgd angles are in opposite sense to gschem's internal angles[0m
[32m+ // Also, gschem's "end_angle" is actually the sweep of the arc, not absolute angle[0m
[32m+[0m
[32m+ // Intialise {start|end}_angle to the start of gschem's sweep[0m
[32m+ start_angle = -o_current->arc->start_angle;[0m
[32m+ end_angle = -o_current->arc->start_angle;[0m
[32m+[0m
[32m+ // libgd always sweeps arcs clockwise so we either update[0m
[32m+ // the start_angle, or end_angle as appropriate[0m
[32m+ if ( o_current->arc->end_angle > 0 )[0m
[32m+ start_angle -= o_current->arc->end_angle;[0m
[32m+ else[0m
[32m+ end_angle -= o_current->arc->end_angle;[0m
[32m+[0m
[32m+ // Ensure each angle is within 0-359. Negative angles make libgd blow up.[0m
[32m+ start_angle = ( start_angle < 0 ) ? 360 - ( (-start_angle) % 360 ) : start_angle % 360;[0m
[32m+ end_angle = ( end_angle < 0 ) ? 360 - ( (-end_angle ) % 360 ) : end_angle % 360;[0m
[32m+[0m
[32m+ // libgd docs state that end angle should always be larger than start_angle[0m
[32m+ if (end_angle < start_angle)[0m
[32m+ end_angle += 360;[0m
width = o_current->arc->screen_width;
height = o_current->arc->screen_height;
_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev