[cairo] Hairline questions

Ian Britten britten at caris.com
Mon Dec 15 10:24:28 PST 2008


Hi all,
Several months ago, I raised a discussion about drawing "thinnest
lines possible" - I believe the terminology you used was hairlines.

First, I was just wondering if anything had happened about that?
I didn't see anything in the (1.8.4) ChangeLog, but I'm not sure
if there's a better place to look for new features, etc...

Second, I've run into a seeming discrepancy (to me, at least), and
wanted to get some clarification...

Based on those previous discussions, I end up doing this to handle
my zero-width lines:
         if (mmThick == 0.0)
         {
                 double tinyThick = 1.0/300.0;
                 double unused = 0;
                 context->device_to_user_distance(tinyThick, unused);
                 context->set_line_width(tinyThick);
         }
         else
         {
                 const double thickUser = mmThick * inMmToUser;
                 context->set_line_width(thickUser);
         }

Now, I have a couple of different cases when drawing polygons:
- With or without the interior filled.
- With and without a separate boundary colour (where the boundary
   is drawn as a thin line).

Looking at two of those cases:
- If I draw the polygon filled, and with a different boundary
   colour, everything looks good.  Basically:
         // set fill attributes
         context->fill_preserve();
         // set boundary attributes
         context->stroke();
- OTOH, if I draw _just_ the boundary without any fill (ie A line),
   then the exact same boundary lines no longer appear.  In fact,
   the resulting PDF file is empty (~800 bytes).

So, does it make sense that what I'm doing for thin lines works
when used for the boundary of filled polygons, but not when used
for drawing lines by themselves?

Thanks for any info, or suggestions about how to best proceed!
Ian


More information about the cairo mailing list