[cairo] Fuzzy lines

Bill Spitzak spitzak at d2.com
Mon Nov 6 10:22:03 PST 2006


He is asking for alignment of lines greater than 1 pixel in thickness. 
That means my idea of turning this on by setting a line width of 0 is 
probably not sufficient. So it sounds like an independent control that 
turns this stroke effect on/off is needed.

Besides adjusting line ends, this should also cause the pen to be 
rounded to the nearest non-zero integer, so you don't also have to 
choose an integer line thickness. If the pen is really an ellipse then 
it is scaled so that the rectangle it is inscribed in is rounded to an 
integer.

This has the added benefit that 0 produces 1-pixel lines.

Piotr Zurek wrote:
> Hi guys,
> 
> I just wanted to ask how do you usually approach the problem of 
> pixel-aligned lines in your applications.
> What I tried to do is to test the current line width before the stroke 
> for each path I draw. If the line width is an odd number I translate it 
> by (0.5, 0.5) and after the stroke, I translate it back by (-0.5, -0.5).
> I'm not really concerned about fills at the moment.
> The problem is that is doesn't really work 100%. Some lines look fine 
> and some don't, e.g. 1 point thick is OK, 2 is OK, 3 is wrong and 4 is 
> OK. Should I also check what the current point is before I create the 
> path and see if the path is drawn at integer coordinates?
> 
> What's the easiest way to get around that problem? Solving that problem 
> globally for all situations is probably a big challenge but at the 
> application level I should be able to work around it somehow. I hope.
> 
> Cheers
> piotr
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo
> 


More information about the cairo mailing list