[cairo] Drawing diagonal lines with antialiasing off

Bill Spitzak spitzak at d2.com
Tue Sep 27 09:56:46 PDT 2005


I still feel this is going to be one of the big annoyances in Cairo and 
will have to be addressed. The fact that the original poster thought 
"turn off antialiasing" was how they got thin lines indicates that a lot 
of people have no idea what is going on or how to fix it, and that their 
attempted solutions are going to make Cairo output look like crap. 
Trying to explain it is hopeless, it just confuses and annoys them, and 
makes a barrier to getting started with Cairo. Some scheme must be come 
up with so that Cairo defaults to a behavior that matches virtually 
every other graphics system in the world.

The solution is that a line width of 0.0 is a special case: Cairo draws 
"thin" but constant-width lines, of 1 pixel on present-day screens. The 
lines are positioned so that horizontal and vertical ones are opaque and 
will cover the antialised edges of any rectangle drawn using the same 
coordinates. Diagonal lines are still antialiased and no guarantee is 
made about them except they will join horizontal and vertical lines. 
Line caps are ignored. The value actually has to be zero, a very tiny 
non-zero value will draw an invisibly-faint antialiased line, and 
negative line widths should act like the absolute value, except they 
flip any asymetrical line caps.

Øyvind Kolås wrote:
> On 9/27/05, Jordi Mas <jordi at ximian.com> wrote:
> 
>>Hi folks,
>>
>>When turning off the antialiasing (CAIRO_ANTIALIAS_NONE) and drawing a
>>vertical line, it gets rendered as two pixel width instead of one.
>>Is there any way using a cairo function to override this behaviour?
>>
>>I'm attaching a very simple case to reproduce the issue and the
>>generated image.
> 
> 
> Your issue is very related to the first entry in the FAQ[1].


More information about the cairo mailing list