[cairo] Drawing diagonal lines with antialiasing off
Gustavo J. A. M. Carneiro
gjc at inescporto.pt
Wed Sep 28 03:57:50 PDT 2005
On Tue, 2005-09-27 at 23:47 -0400, Jason Dorje Short wrote:
> Bill Spitzak wrote:
> > 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.
>
> Xlib has a fixed definition of how a line is drawn, which is based on
> integer coordinates (I've read this definition before but now I can't
> find it). Cairo has a different definition that uses floating-point
> coordinates.
>
> Obviously the definitions differ for width-1 lines, but I don't think a
> special case for 0 is a workable solution; it's just a hack and will
> give wrong behavior in some cases (a width0 line should be width 0,
> after all).
Agreed. This width-0 special behaviour induces developers to make
shortcuts that prove disastrous later on. For example, a developer
might use width-0 lines in some places because they look great on his
1024x768 screen. But then you run the application on a 1600x1200
display and it looks too thin. Or on a 600dpi printer it looks even
worse. And in a vector drawing program if you zoom it (apply scale
matrix transformation), the zero-width line stays with the same width,
which is not what you normally want.
Regards.
--
Gustavo J. A. M. Carneiro
<gjc at inescporto.pt> <gustavo at users.sourceforge.net>
The universe is always one step beyond logic.
More information about the cairo
mailing list