[cairo] Drawing diagonal lines with antialiasing off

Gustavo J. A. M. Carneiro gjc at inescporto.pt
Wed Sep 28 14:16:07 PDT 2005


On Wed, 2005-09-28 at 11:52 -0700, Bill Spitzak wrote:
> 
> Gustavo J. A. M. Carneiro wrote:
> 
> >   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.
> 
> No, they will look correct on the different resolution. The "0 width" 
> lines I am proposing will hide antialiased edges of orthogonal 
> rectangles.

  You are mixing two features into one.  "0 width" is one thing, "hide
antialiased edges of orthogonal rectangles" is another.  Even though you
may be able to optimise or simplify code considering both features used
together, they are in essence different.  This happens if you only do
"hide antialiased edges of orthogonal rectangles" for the 0-width case:

	1- Developer will draw width=1 lines;
	2- Developer notices fuzzyness due to lack of grid fitting;
	3- Developer switches to width=0 lines, to solve the fuzzyness problem;
	4- 6 months later a user complains that lines are too thin, asks for
configurable line width;
	5- Developer has to go back and do the grid fitting anyway (and it's
harder now to navigate through the old code), or (more likely) tells the
user to take a hike;

>  Thus if the scale is an unexpected amount you will still get 
> sharp lines and they will draw directly over any antialiased rectangle 
> edges that you did not expect.

>  Your proposal of a line width of 1 and .5 
> offset will draw fuzzy lines of more than 1 pixel if the transformation 
> is an unexepected amount.

  I didn't propose that.  I didn't anything, in fact.  It was a purely
destructive post ;)

> 
> > Or on a 600dpi printer it looks even
> > worse.
> 
> PostScript solved this long ago. A zero linewidth draws a "hairline" 
> which is thick enough to produce a visible image. On a 600 dpi printer 
> it is actually several pixels thick.

  Yes, I know that, and I hate it.  I always feel deceived when I see a
shape in a drawing program with acceptable line widths but then I get
very thin lines when I print it.  I think XFig used to have this
annoying behaviour.  

  I fear that introducing this zero-width API feature into Cairo makes
it very tempting for developers to use this left and right even when it
should not be used.  Although it does have its uses.

> 
> > 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.
> 
> Actually I think that behaivor is *VERY* desirable! Programs use this 
> all the time for guidelines that are not part of the final diagram.

  True, that is one good use-case.  Zero-width lines can be interesting
feature, but like I said it's dangerous to solve the fuzzyness issue
just for this special case, IMHO.

  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