[cairo] Rotating patterns (sprites)?
Ian Britten
britten at caris.com
Tue Sep 8 08:56:36 PDT 2009
Hi all,
Continuing on with the pattern (sprite) drawing questions I was
asking last week, I have a couple more questions, mostly focused
on rotation. [ NB - Cairo v1.8.8 ]
Goal:
- Draw my patterns/sprites to an output surface that has a
rotation angle set in it.
- Get my patterns to be rotated the same amount.
- Draw my patterns at specific user positions.
Attached is an updated sample program. When drawn with no rotation
angle, it draws a diagonal line through two user positions (Sanity
check), then draws a grid of 16 sprites, which point downwards.
Note that for now, I'm just drawing the corner of the pattern at
the desired position, but ideally/eventually, it'll be the centre
of the sprite at the position.
Problems:
- When I set a rotation on the output surface, the sprites don't
actually rotate - They still point downwards. Shouldn't
painting a pattern onto a rotated surface result in a rotated
pattern?
If not, how should I best proceed? Rotate the sprite when
drawing my original data into it? Or muck about with the
matrix of the [surface?|sprite?] when trying to paint it?
- When the rotation is set, most of my sprites disappear. I
assume this is due to my translate/set_matrix() calculations,
and not accounting for the rotation of the output somehow.
Is this something I should really have to do though? I don't
have to calculate/rotate the points for lines. Can't I just
(somehow) specify the user position I want the pattern at, and
let Cairo handle the transformations, the way it does for lines?
Doesn't it seem kindof non-symmetrical that I can draw lines in
user units, but not patterns?
- How the heck do most people debug this sort of problem? When
the data simply doesn't appear, how do you know where it is?
- Finally, can I achieve the effect I need fairly easily? Or is
this going to require a bunch of matrix stuff? :P
Many thanks for any help!
Ian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sprite.c
Type: text/x-csrc
Size: 4459 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20090908/4b04314d/attachment.c
More information about the cairo
mailing list