[cairo] Polygon fill styles?

Ian Britten britten at caris.com
Thu Aug 21 12:17:26 PDT 2008

Ian Britten wrote:
> Kalle Vahlman wrote:
>> Then you use
>> cairo_pattern_create_for_surface() to create a pattern of the surface.
>> To get it repeated, you simply set the extend mode for the pattern
>> with cairo_pattern_set_extend() to CAIRO_EXTEND_REPEAT.
>> Then you draw your polygon, but instead of setting the source to a
>> color like normal solid fills, you set the previously created pattern
>> as the source with cairo_set_source().
>> Easy as pie, no?
> Sound like it, once I get the patterns made...  I may have more
> questions at that time though.

Would anyone have a few minutes that they could look at (or try) the
self-contained (cairomm) sample I've attached, to explain what I'm
doing wrong regarding the size/scaling of the patterns?

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.

What I'm trying to do is make a 5mm surface for the pattern, draw
an X in it, and tile the polygon with it.  Note that it's intended
to be 5mm on the final output PDF, irregardless of the user-unit
cover being used.  In this example, the 5mm tile is about 14 device
units on my output PDF (according to user_to_device_distance()),
and should give at most 40 rows+columns of the pattern.

What I'm seeing though is the pattern scaled incorrectly depending
on the magnitude of the user unit cover I use, resulting in many
more/less tiles than I'd expect, and none of them seem to be the
desired 5mm.  For example, if I add/remove zeros to the cover, the
size of the pattern changes in the resulting PDF, and I wouldn't
have expected it.  Note that what really confuses me is that
irregardless of the user-unit cover I use, the 'device size' I
calculate is always 14, as expected, but the result doesn't look
anything like that.

I'm suspecting there is more going on behind the scenes than I
(currently) understand, but I just don't see what it is...  :(
[ OTOH, I might just be confused...  :) ]

Many thanks for any help/explanation!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 4506 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080821/3acec9e9/attachment.cpp 

More information about the cairo mailing list