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

gEDA-cvs: gaf.git: branch: master updated (1.5.1-20081221-151-g807f3d8)



The branch, master has been updated
       via  807f3d81883ce8075d41588f41e67ea19fd6bef3 (commit)
      from  8ca598852f51c04183ab872f35bcc156628bdf79 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gschem/src/gschem_cairo.c |   63 ++++++++++++++++++++++++++++++++------------
 1 files changed, 46 insertions(+), 17 deletions(-)


=================
 Commit Messages
=================

commit 807f3d81883ce8075d41588f41e67ea19fd6bef3
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Mon Jan 5 16:57:38 2009 +0000

    gschem: Calculate radius of centered arcs and boxes with 2x precision
    
    Since we may have to hint the radius by 0.5px to bring it onto the
    pixel grid, we will get better results if we compute the radius to
    half-pixel precision.
    
    Re-enable radius hinting for centered arcs back on, but only for arcs
    which have radius > 1px to start with. If we don't, there is an abrupt
    transition between when the arc lights a single pixel, and when it is
    the next largest size. A little anti-aliasing in that case helps.

:100644 100644 9f5255a... e9a8e5c... M	gschem/src/gschem_cairo.c

=========
 Changes
=========

commit 807f3d81883ce8075d41588f41e67ea19fd6bef3
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Mon Jan 5 16:57:38 2009 +0000

    gschem: Calculate radius of centered arcs and boxes with 2x precision
    
    Since we may have to hint the radius by 0.5px to bring it onto the
    pixel grid, we will get better results if we compute the radius to
    half-pixel precision.
    
    Re-enable radius hinting for centered arcs back on, but only for arcs
    which have radius > 1px to start with. If we don't, there is an abrupt
    transition between when the arc lights a single pixel, and when it is
    the next largest size. A little anti-aliasing in that case helps.

diff --git a/gschem/src/gschem_cairo.c b/gschem/src/gschem_cairo.c
index 9f5255a..e9a8e5c 100644
--- a/gschem/src/gschem_cairo.c
+++ b/gschem/src/gschem_cairo.c
@@ -131,16 +131,31 @@ void gschem_cairo_center_box (GSCHEM_TOPLEVEL *w_current,
                               int half_width, int half_height)
 {
   int s_center_width, s_line_width;
-  int s_half_width, s_half_height;
+  int s_width, s_height;
+  double s_half_width, s_half_height;
   int s_x, s_y;
   int even_center_width;
   int even_line_width;
+  int even_width, even_height;
   double x1, y1, x2, y2;
-  double center_offset, radius_offset;
+  double center_offset;
+  int do_width_hint = TRUE;
+  int do_height_hint = TRUE;
 
   WORLDtoSCREEN (w_current, x, y, &s_x, &s_y);
-  s_half_width  = SCREENabs (w_current, half_width);
-  s_half_height = SCREENabs (w_current, half_height);
+  s_width  = SCREENabs (w_current, 2 * half_width);
+  s_height = SCREENabs (w_current, 2 * half_height);
+  even_width  = (s_width % 2 == 0);
+  even_height = (s_width % 2 == 0);
+  s_half_width  = (double) s_width  / 2.;
+  s_half_height = (double) s_height / 2.;
+
+#if 0 /* Not as nice an effect as with arcs */
+  /* Switch off radius hinting for small radii. If we don't, then we get
+   * a very abrupt transition once the box reaches a single pixel size. */
+  if (s_half_width  <= 1.)  do_width_hint  = FALSE;
+  if (s_half_height <= 1.)  do_height_hint = FALSE;
+#endif
 
   /* Hint the center of the box based on where a line
    * of thickness center_width (world) would drawn */
@@ -151,12 +166,17 @@ void gschem_cairo_center_box (GSCHEM_TOPLEVEL *w_current,
   /* Hint the half-widths to land the stroke on the pixel grid */
   s_line_width = screen_width (w_current, line_width);
   even_line_width = (line_width == -1 || (s_line_width % 2) == 0);
-  radius_offset = (even_center_width == even_line_width) ? 0. : 0.5;
-
-  x1 = (double) s_x + center_offset - s_half_width  - radius_offset;
-  y1 = (double) s_y + center_offset - s_half_height - radius_offset;
-  x2 = (double) s_x + center_offset + s_half_width  + radius_offset;
-  y2 = (double) s_y + center_offset + s_half_height + radius_offset;
+  if (do_width_hint)
+    s_half_width  += ((even_center_width ==
+                             even_line_width) == even_width ) ? 0. : 0.5;
+  if (do_height_hint)
+    s_half_height += ((even_center_width ==
+                             even_line_width) == even_height) ? 0. : 0.5;
+
+  x1 = (double) s_x + center_offset - s_half_width;
+  y1 = (double) s_y + center_offset - s_half_height;
+  x2 = (double) s_x + center_offset + s_half_width;
+  y2 = (double) s_y + center_offset + s_half_height;
 
   /* Allow filled boxes (inferred from line_width == -1)
    * to touch an extra pixel, so the filled span is inclusive */
@@ -224,13 +244,22 @@ void gschem_cairo_center_arc (GSCHEM_TOPLEVEL *w_current,
                               int radius, int start_angle, int end_angle)
 {
   int s_center_width, s_line_width;
-  int s_x, s_y, s_radius;
+  int s_x, s_y, s_diameter;
   int even_center_width;
   int even_line_width;
-  double center_offset, radius_offset;
+  int even_diameter;
+  double center_offset;
+  double s_radius;
+  int do_radius_hint = TRUE;
 
   WORLDtoSCREEN (w_current, x, y, &s_x, &s_y);
-  s_radius  = SCREENabs (w_current, radius);
+  s_diameter = SCREENabs (w_current, 2 * radius);
+  even_diameter = ((s_diameter % 2) == 0);
+  s_radius = (double) s_diameter / 2.;
+
+  /* Switch off radius hinting for small radii. If we don't, then we get
+   * a very abrupt transition once the arc reaches a single pixel size. */
+  if (s_radius <= 1.) do_radius_hint = FALSE;
 
   /* Hint the center of the arc based on where a line
    * of thickness center_width (world) would drawn */
@@ -241,13 +270,13 @@ void gschem_cairo_center_arc (GSCHEM_TOPLEVEL *w_current,
   /* Hint the radius to land its extermity on the pixel grid */
   s_line_width = screen_width (w_current, line_width);
   even_line_width = (line_width == -1 || (s_line_width % 2) == 0);
-  /* radius_offset = (even_center_width == even_line_width) ? 0. : 0.5; */
-  /* Don't hint the radius, it makes things look strange when drawing cues */
-  radius_offset = 0.;
+  if (do_radius_hint)
+    s_radius += ((even_center_width ==
+                        even_line_width) == even_diameter) ? 0. : 0.5;
 
   do_arc (w_current->cr, (double) s_x + center_offset,
                          (double) s_y + center_offset,
-                         (double) s_radius + radius_offset,
+                         (double) s_radius,
                          start_angle, end_angle);
 }
 




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