[cairo] Polygon fill styles?

Ian Britten britten at caris.com
Fri Aug 22 04:38:31 PDT 2008


Bertram Felgenhauer wrote:

>> Basically, I've made a square PDF surface, mapped a square user-unit
>> cover into it, and drawn a simple diamond polygon into it.  This
>> works no problem, irregardless of the of the user unit cover I use.
>>
>> When I try to add a pattern to the polygon, the resulting output
>> doesn't match my expectation, nor do the numbers I'm seeing in the
>> debugger match the result.
> 
> This would be because when you call context->set_source, the current
> transformation of the context gets applied to the pattern.

Ahhh, that explains what's going on!  I really appreciate you taking
the time to look at this!

[snip]

> Alternatively, you can temporarily reset the context's transformation
> matrix to the identity to get the behaviour that you probably expected.

Yep, that seems to work.
I had tried changing the transformation of my temporary context, but
I hadn't thought about altering the destination context...

> Thirdly, you can set a transformation on the pattern itself, using
> set_matrix(). The effect is somewhat counter-intuitive (it applies the
> inverse transformation of the matrix to the pattern);

Interesting.  With that info, it seems that if I set the matrix from
the destination context into the pattern, before setting the pattern
into the context, it works too (Since it gets inverted, as described).
I'm still experimenting, but this seems like it might be my cleanest
solution, as I don't have to modify my destination context any.

Anyways, you've provided me with the info I needed, plus several
viable solutions - My sincere thanks!
Ian



More information about the cairo mailing list