[cairo] measure needed canvas size
Sam Tygier
samtygier at yahoo.co.uk
Tue Mar 15 10:36:22 PDT 2011
hi
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
png).
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 am using cairo though python, if that makes a difference.
thanks
sam
More information about the cairo
mailing list