[cairo] Negative coordinates with recording surfaces

Antony Lee antony.lee at berkeley.edu
Thu Jul 6 07:28:08 UTC 2017


Hi all,

I have am a bit puzzled with how negative coordinates interact with
recording surfaces.  Consider the following cairocffi example:

from cairocffi import *
surf = RecordingSurface(CONTENT_COLOR_ALPHA, None)
ctx = Context(surf)
ctx.move_to(-5, -5)
ctx.line_to(5, 5)
ctx.set_line_width(.001)  # so that ink extents are not affected by
linewidth
ctx.stroke()
print(surf.ink_extents())


This gives (-5.0, -5.0, 10.0, 10.0), so ink_extents has correctly reported
that we have something going from (-5, -5) to (5, 5) on the unbounded
surface.

But replace the surface constructor call by

surf = RecordingSurface(CONTENT_COLOR_ALPHA, (-10, -10, 20, 20))


which is a surface that is large enough to cover our line.  (After all, the
documentation encourages us to specify the extents, for better performance.)
Now the same program gives (5.0, 5.0, 5.0, 5.0).  By playing around with
the numbers, I *guess* that the origin is relative to the lower left corner
of the recording surface, and the width and height are up to 0, 0 but not
beyond?

Shouldn't I get instead either (-5.0, -5.0, 10.0, 10.0) (same as with an
unbounded surface), or at least (5.0, 5.0, 10.0, 10.0) (if the returned
extents are relative to the lower left corner of the surface)?

Thanks in advance,

Antony Lee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20170706/0b3bc7bd/attachment.html>


More information about the cairo mailing list