[cairo] Hairlines

Carl Worth cworth at cworth.org
Wed Jan 28 23:17:18 PST 2009


On Wed, 2009-01-28 at 12:00 -0400, Ian Britten wrote:
> > Sometimes it is deceptive when hairlines in a low-resolution display to 
> > appear thicker relatively to other (non-hairline) lines, while thinner 
> > (almost too thin to see) in very high resolution displays.
> 
> This is a different issue, I believe.  How a particular application
> downsamples and presents data on a particular monitor has nothing to do
> with how the initial data file is created (Which is the case I'm trying
> to address at the moment)
> [ If I'm wrong though, please enlighten me!  :) ]

I think Gustavo's point is that if we add a "hairline mode" that draws a
1.0/300.0 device-pixel line in PDF output, but a 1.0 device-pixel line
in image-surface output, then those hairlines can look wildly different
in comparison to other elements. For example, the PDF hairlines could
look much thinner than non-hairline elements, while the image hairlines
would look much thicker than the same elements.

I think the fundamental problem you are dealing with is that
low-resolution devices are simply less capable than high-resolution
devices. I know that I wish I could always ignore pixels, but the fact
is that I can't yet. (I wrote a little bit of line-chart-drawing code
this week and I was amazed at how much math I had to do to get the
scaling set up just right so that the frame and tick marks would align
to pixel bounaries.)

It sure would be great to not have to worry about issues like that. But
I only see that happening when we are using high-resolution devices
everywhere, (that is, not soon). In the meantime, I'm still not in favor
of cairo choosing to draw elements at sizes or positions other than you
ask for.

But, the feature you are wanting here should be something that you can
implement on top of cairo just fine. You should be able to write a
little function like:

	_stroke_hairline (cairo_t *cr);

which can cairo_save(), examine the device-pixel size, set up an
identity matrix, choose an appropriate line width based on the
device-pixel size, cairo_stoke(), and then cairo_restore().

Once you've got that working I think you'll have a much more concrete
proposal for what you would like to see implemented in cairo.[*]

-Carl

[*] But on the other hand, you'll also have an existence proof of why it
doesn't *have* to be implemented in cairo either. ;-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.cairographics.org/archives/cairo/attachments/20090128/56477bb4/attachment.pgp 


More information about the cairo mailing list