[cairo] Pattern questions

Ian Britten britten at caris.com
Thu Sep 3 06:32:02 PDT 2009


Hi all,
    [ cairo 1.8.8 ]
I'm trying to do some basic work with patterns, and I was hoping
someone could clarify a couple of things:

My goal:
- Make a pattern (stencil), and use it to draw multiple times at
   multiple user positions on my output surface.  The result should
   work for any surface type (But primarily Image and PDF).

My concerns:
- Correctness (and performance)
- Positioning


Attached is a basic sample that I'm working with.  In it, I can
create my pattern/stencil correctly, and it looks correct when
I save it to PNG (That's a handy feature, BTW!)

Also, I can get it to draw, but, well...
- Is cairo_paint() the correct (and efficient) way to draw each
   pattern?  I had initially been trying to use move_to()/stroke()
   but obviously that didn't work.
   - I seem to recall discussions about embedding+reusing patterns
     in some output surfaces (PDF?), and wasn't sure if using paint()
     would result in that being done (Assuming it actually is done).
   - paint() sounds like a whole-surface operation (Sortof like a
     full pixmap copy).  Is it the best way to draw a single pattern,
     that is only being drawn at a known position on the surface?
     In some workflows, I could be drawing many small patterns on a
     single surface in one operation.
- Can someone describe (or point me to) some info about positioning
   the patterns?  Especially about where their initial position is.
   - For example, irregardless of the transformation I set on my
     outputSurface, my first paint() always seems to put the device
     origin of my pattern at the device origin of the surface ...?
     And subsequent translate() calls move it by that user amount of
     output units?  (Negative though, it seems...)
   - What I really need to do is draw my pattern centred at
     specified user positions on my outputSurface.
   Basically, I still can't get my 'real' code to draw patterns,
   and I'm concluding it's because I don't really understand some of
   the basics well enough...

Many thanks for any help! (And/Or critique/suggestions/info!)
Ian


-------------- next part --------------
A non-text attachment was scrubbed...
Name: stencil.c
Type: text/x-csrc
Size: 3164 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20090903/47bbd3f8/attachment-0001.c 


More information about the cairo mailing list