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

Peter TB Brett peter at peter-b.co.uk
Tue Apr 17 06:00:53 EDT 2007


On Tuesday 17 April 2007 10:38:20 Bernd Jendrissek wrote:
>
> 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;
> +  }

How about something along these lines:

   angle = start_angle + 180 % 360;

   gdk_draw_arc (gport->drawable, gport->u_gc, 0,
                DRAW_X (cx) - vrx, DRAW_Y (cy) - vry,
                vrx * 2, vry * 2, angle * 64, delta_angle * 64);

This avoids a branch, and requires fewer instructions. OTOH, can start_angle 
be negative?

Cheers,

Peter


-- 
Fisher Society committee                    http://tinyurl.com/o39w2
CUSBC novices, match and league secretary   http://tinyurl.com/mwrc9
CU Spaceflight                              http://tinyurl.com/ognu2

v3sw6YChw7$ln3pr6$ck3ma8u7+Lw3+2m0l7Ci6e4+8t4Gb8en6g6Pa2Xs5Mr4p4
  hackerkey.com                                  peter-b.co.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.seul.org/pipermail/geda-dev/attachments/20070417/edd134e2/attachment.pgp


More information about the geda-dev mailing list