Imagine making a lasso selection tool by yourself, and want to figure out if a certain node is located inside the lasso-drawn path. What is the best way to do this?
Never mind, I think I’ve got it.
If you have an NSBezierPath, try this function: NSBezierPath.containsPoint_(p)
where p is an NSPoint.
1 Like
Thanks!
Before I found this topic, I was trying to do the same thing with the containsNode_() method for GSPath (found that while digging into help(GSPath)) but that never worked, ex:
for n in path1.nodes:
if path2.bezierPath.containsPoint_(NSPoint(n.x,n.y)):
print n
is working properly, but
for n in path1.nodes:
if path2.containsNode_(n):
print n
never returns anything. I ended up getting help for doing what I needed to do with a fonttools pen, but just out of curiosity, how does that containsNode_() method working?
myPath.containsNode_(myNode)
… is equivalent to:
myNode in myPath.nodes
Ok, so not at all what I thought it would do thanks Rainer!
1 Like