[cairo] masking in herds
Donn
donn.ingle at gmail.com
Tue Nov 6 02:17:44 PST 2007
Me again.
Right, nailed transform and rotate. Nailed alpha-ing. Time for masking. I have
some fun code which I'll share soon.
class Box:
def draw():
<cairo commands to draw a box>
class Circle:
def draw():
<cairo draws a red circle>
Box.draw() results in a blue box.
Circle.draw() a red circle.
How can I wrap Box.draw() so that the circle is cropped by the box.
<cairo voodoo mask begin>
<cairo voodoo use Box.draw()>
Circle.draw()
OtherStuff.draw()
<cairo voodoo mask ends>
The problem is, I think, is that the mask command takes a ref to a cairo
object *not* a complete set of <cairo commands>.
self.context.mask(self.radial): self.radial is the rub.
I have Box.draw() to offer and it includes stroke and fill etc. i.e. a
completed drawing unit.
I can change the return value of the Box.draw() function to return an object
that can go into mask() but it breaks the overall concept of my idea, which
is: The children of an object are masked by the <cairo commands that draw
stuff> of that object.
Whatever goes into the object is masked by it's "shape". In the end a "Thing"
may be many shapes (whatever it contains, let's say 2 squares and a
dinosaur) - I want them *all* to act as one big mask should the thing be
flagged as a mask. Thereafter whatever sub-things are drawn under this thing
will be masked by a two-square-o-saur.
After writing that I sort of see the push_group thing in my immediate
future :)
Hope that makes sense.
\d
More information about the cairo
mailing list