[cairo-commit] cairo-demo/png snapping.c,1.2,1.3
Carl Worth
commit at pdx.freedesktop.org
Mon Oct 25 08:21:03 PDT 2004
Committed by: cworth
Update of /cvs/cairo/cairo-demo/png
In directory gabe:/tmp/cvs-serv3017
Modified Files:
snapping.c
Log Message:
* snapping.c (snap_point_for_fill, snap_point_for_stroke)
(snap_line_width): Switch from integer truncation to floor() so
that rounding works as desired with negative numbers.
Index: snapping.c
===================================================================
RCS file: /cvs/cairo/cairo-demo/png/snapping.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- snapping.c 22 Oct 2004 15:52:26 -0000 1.2
+++ snapping.c 25 Oct 2004 15:21:00 -0000 1.3
@@ -64,8 +64,8 @@
{
/* Convert to device space, round, then convert back to user space. */
cairo_transform_point (cr, x, y);
- *x = (int) (*x + 0.5);
- *y = (int) (*y + 0.5);
+ *x = floor (*x + 0.5);
+ *y = floor (*x + 0.5);
cairo_inverse_transform_point (cr, x, y);
}
@@ -100,8 +100,8 @@
y_offset = y_width_dev_2 - (int) (y_width_dev_2);
cairo_transform_point (cr, x, y);
- *x = (int) (*x + 0.5 + x_offset);
- *y = (int) (*y + 0.5 + y_offset);
+ *x = floor (*x + x_offset + 0.5);
+ *y = floor (*y + y_offset + 0.5);
*x -= x_offset;
*y -= y_offset;
cairo_inverse_transform_point (cr, x, y);
@@ -124,11 +124,11 @@
cairo_transform_distance (cr, &x_width, &y_width);
- x_width_snapped = (int) (x_width + 0.5);
+ x_width_snapped = floor (x_width + 0.5);
if (x_width_snapped < 1.0)
x_width_snapped = 1.0;
- y_width_snapped = (int) (y_width + 0.5);
+ y_width_snapped = floor (y_width + 0.5);
if (y_width_snapped < 1.0)
y_width_snapped = 1.0;
More information about the cairo-commit
mailing list