[cairo] Cairo is non-deterministic?
vladimirv at gmail.com
Mon Jan 2 06:11:16 PST 2006
Your path creation is a little strange there.. in particular, the
current path is not part of the gstate, so saving/restoring has no
effect on it. Also, close_path() is a path operation, adding a
lineto() from the current point to the start of the path -- doing it
after stroke() doesn't really make sense, since the stroke() will
consume the path. (stroke_preserve doesn't, but it still doesn't make
sense the way you're using it). rel_move_to is also a path command,
and not a translation matrix command
The reason why things don't work if you invert the two blocks is that
you end up drawing very different paths when you switch the order.
I'd suggest you structure your rendering like this:
# draw up
# draw line
rel_line_to(...) # draw your line bits
Note that the new_path()'s aren't strictly necessary, but it's good
defensive programming in case someone left a path in the context
you're drawing to.
On 1/2/06, Lawrence Oluyede <l.oluyede at gmail.com> wrote:
> I'm using Cairo (with pycairo) for a test project and meanwhile I'm
> gonna learn to use it but I'm "worried" about somethings that I can't
> handle. Why this works:
> def draw_rows(self):
> # move down to the border position
> self.context.rel_move_to(200, 30)
> # draw one segment up
> self.context.rel_line_to(0, -100)
> # draw an horizontal line (unit = 10 pixels)
> unit = 10
> for i in range(4):
> self.context.rel_line_to(unit, 0)
> and the same with "draw one segment up" block written after the "draw
> an horizontal line" doesn't?
> Is there something I'm missing?
> cairo mailing list
> cairo at cairographics.org
More information about the cairo