[cairo] measure needed canvas size
ranma42 at gmail.com
Tue Mar 15 10:41:04 PDT 2011
On Tue, Mar 15, 2011 at 6:36 PM, Sam Tygier <samtygier at yahoo.co.uk> wrote:
> i want to draw a diagram, 2d CAD layout sort of thing. i have a list of various
> shapes and lines and their positions and rotations in physical space. and i have
> a function that takes this list and draws it to a context of a surface (pdf or
> i'd like a way to know the maximum required space, so that i can choose a size
> for the canvas. currently i have a function that goes through the list and works
> out the coordinate of each point that needs to be drawn, and keeps a max_x,
> max_y, min_x, min_y. this function is very like my drawing function, which seems
> wasteful. also when the 2 functions diverge (when i add a new shape to the draw
> function) then the bounds get messed up.
> i am now wondering about making a dummy context object that ignored all but a
> few functions (move_to(), line_to()), and instead of drawing anything, just
> records max_x, max_y, min_x, min_y.
> this seems to me like it must be a common problem. is there a better solution?
> is there already such a dummy context?
I believe this is what you're looking for:
> i am using cairo though python, if that makes a difference.
> cairo mailing list
> cairo at cairographics.org
More information about the cairo