[cairo] Aligning graphics with the device pixel grid

Carl Worth cworth at cworth.org
Fri Oct 22 12:55:49 PDT 2004


On Fri, 22 Oct 2004 12:08:18 -0700, Bill Spitzak wrote:
> ROUNDING:
> 
> Doing int(x+.5) is bad because the whole thing shifts when it passes through 
> the origin. Use floor(x+.5).

Thanks. Owen had already pointed out that (int)(x+.5) was wrong.

I was going to switch to round(x), but it appears that breaks the tie
the wrong direction (always away from zero).

So, it looks like floor(x+.5) is indeed what we want here.

-Carl




More information about the cairo mailing list