Hi @micycle ,
The vertex codes will not match the number of vertices. For a cubic Bezier vertex, there will be 3 pairs (6 floats) in vertices per command; for a quadratic Bezier vertex 2 pairs (4 floats) in vertices per command. That’s why this happens when a shape that should be a PATH
family
is assigned the GEOMETRY
family instead.
beginContour inserts a BREAK
command into the vertex commands list, so maybe you could use that in conjunction with a vertex winding algorithm to get what you’re looking for.
(Also, beware of implementation differences between a super-class PShape
and its sub-classes, for example PShapeOpenGL
).
EDIT: When I wanted to convert between a PShape and my own 2D curve class, I used this routine to loop through the commands. The code does not address contours but it may offer a basic outline.
Hope that helps some, Jeremy