Zoom to fit

133 views
Skip to first unread message

Molchanov Timophey

unread,
May 7, 2013, 10:15:36 AM5/7/13
to pap...@googlegroups.com
Hi all! I am a creator of sharedwg.com. And i'm using paper.js for painting features. 
But i don't really understand how can i create "zoom to fit" tool.
So i need to zoom in if there are small pictute on canvas, or zoom out if there meny paths and rasters all around the canvas. 
Is anybody have any ideas about that?

Colin Kingsbury

unread,
May 13, 2013, 10:10:40 AM5/13/13
to pap...@googlegroups.com
Look at the bounds property of Item. This is supposed to give you the bounding rectangle of an item. If you have several items in your drawing you could iterate over them to get the maximum X and Y values for all of them.

The View object is where you can configure the zoom factor, etc. 
http://paperjs.org/reference/view

Hope that helps
Reply all
Reply to author
Forward
0 new messages