Posted by Mark M on Jan 30, 2008
You can get the rectangular bounds of a bezier path by calling the bounds method on the underlying nsbezierpath object. This may not be a documented feature, so there is guarantee that it will always work. This will give you the rectangular bounds.
Probably easier with an example:
nofill() stroke(0) autoclosepath(close=False) ## Create Path beginpath(87,200) curveto(347, 32, 144, 588, 409, 326) p = endpath() ## call bounds method on underlying cocoa path object ## this returns an NSRect which can be treated like a 2x2 array ## representing the top left-hand corner and the width and height bounds = p._nsBezierPath.bounds() rect(bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1])
Posted by A. Mao on Jan 31, 2008
Thank you!
Geometric boundaries for any path
Posted by A. Mao on Jan 30, 2008Hello,
Is there an easy way to get geometric boundaries for any given path?