[cairo] Adventures in line widths

Christopher Barker Chris.Barker at noaa.gov
Fri Apr 28 11:49:07 PDT 2006

Carl Worth wrote:
> So that would be adding the following two lines to your code:
> 	   ctx.restore()
> 	   ctx.save()

Thanks, that solved it. I figured there should be a way to do that!

> One thing worth noting here is that using save/restore around the
> scaling/path creating only works because we decided not to make the
> path part of the graphics state in cairo. That is, the restore does
> not restore the path back to what it was before save.

This is a bit beyond me, but I'm starting to get it.

Since you were so helpful with that, I've another question. I'm still 
getting used to the whole path - stroke - fill model of drawing. I tend 
to think more in terms of objects:

"I want a Polygon with a 5 pixel wide black line, filled with Blue"

I mostly use wxPython, so I'm used to the wxWidgets Device Context 
model. I'm learning that this is really pretty limited, but it still 
fits my brain better.

Anyway, the problem at hand is this: If I want to draw an object with a 
fill and fat stroke, I can set up the path, then fill_preserve it, then 
stroke it. That works fine for opaque objects, but if I do that with an 
alpha channel, the stroke gets alpha blended into the fill, so that half 
the line looks like I want, but the other half is a half-color. This 
isn't too bad with a thin stroke but if the stroke is pretty fat, it 
really doesn't look right.

I've enclosed a PNG of an example. The same rectangle rendered on a 
white background, one with alpha = 1.0, and one with alpha = 0.5

Is there any solution to this?



Christopher Barker, Ph.D.
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: junk7.png
Type: image/png
Size: 1242 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060428/5d44cab1/junk7.png

More information about the cairo mailing list