[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-dev: [PATCH] PCB/gtk: Draw rotated arcs correctly



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

Hi all,

I noticed that my TO3_90 elements were getting borked when I rotated
them.  Looks like libX11 keeps angles in a 'short', so the TO3_90 ended
up overflowing that value.  The start_angle of 340 degrees gets passed
to GDK then X11 as (340 + 180 = 520) * 64 = 33280; some signed integer
overflow later and you have an arc starting at 216 degrees from 3
o'clock.

This patch fixes it:

diff -up ./src/hid/gtk/gtkhid-main.c.borig ./src/hid/gtk/gtkhid-main.c
--- ./src/hid/gtk/gtkhid-main.c.borig	2007-04-16 17:56:08.000000000 +0200
+++ ./src/hid/gtk/gtkhid-main.c	2007-04-17 11:23:09.000000000 +0200
@@ -649,6 +649,10 @@ ghid_draw_arc (hidGC gc, int cx, int cy,
 		start_angle =-start_angle + 180;;
 		delta_angle = -delta_angle;;
 		}
+  /* Prevent overflow in X11. */
+  if (start_angle + 180 >= 360) {
+    start_angle -= 360;
+  }
   gdk_draw_arc (gport->drawable, gport->u_gc, 0,
 		DRAW_X (cx) - vrx, DRAW_Y (cy) - vry,
 		vrx * 2, vry * 2, (start_angle + 180) * 64, delta_angle * 64);
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGJJWAwyMv24BBd/gRAsVJAJ9pCqYqZbRqUvTg5HjhUHrEffO9xwCaAsgz
pr9bNxcttxs7ZgB2DFF75pY=
=ym01
-----END PGP SIGNATURE-----


_______________________________________________
geda-dev mailing list
geda-dev@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev