I am just starting to learn how to work with NS-classes. Right now I am trying to figure out how it is possible to index through and access certain parts of a NSBezierPath.
In the snippet below there is a circular path that has 12 nodes and 4 segments. I would like to be able to know how to index and cycle through each of those nodes/segments and apply thickness/color. I can tell the parts in the code that make up the segments but I don't know how to access them.
Simply put, as an example, I would like to be able to: - select a path - select it's 3rd segment - give it some thickness - color it blue
I been looking at the AppKit documentation and it seems the codes below are what I need but I honestly have no idea of how to apply them.
func element(at index: Int) -> NSBezierPath.ElementType
func element(at index: Int,
associatedPoints points: NSPointArray?) -> NSBezierPath.ElementType
https://developer.apple.com/documentation/appkit/nsbezierpath/1520751-element?changes=_5
I would greatly appreciate any help and examples to better understanding how to work with these methods and apply them.
SNIPPET:
for path in layer.paths:
bp = path.bezierPath
bp.setLineWidth_(5)
NSColor.blueColor().set()
bp.stroke()
print bp
PRINTS OUT THIS:
Path <0x60400553f0e0>
Bounds: {{157, 0}, {286, 286}}
Control point bounds: {{157, 0}, {286, 286}}
300.000000 0.000000 moveto
379.000000 0.000000 443.000000 64.000000 443.000000 143.000000 curveto
443.000000 222.000000 380.000000 286.000000 300.000000 286.000000 curveto
221.000000 286.000000 157.000000 222.000000 157.000000 143.000000 curveto
157.000000 64.000000 221.000000 0.000000 300.000000 0.000000 curveto
closepath
300.000000 0.000000 moveto