PShape with Cutout - Inner Contour
Last updated
Last updated
The image below shows how vertex points can be specified as a fractional value of len, the input parameter for our PShape functions.
The drawing shows the points that are specified in the code below. You will want to draw a similar diagram to determine points for your custom shape vertices. Notice that points used for the cutout-inner-contour are specified in counter-clockwise manner. The last point for the outershape is (0,0), it's not re-numbered in the drawing, instead, the point with label 5 has values: s.vertex(.25len, .45len), it is located near point 4 on the drawing.
The code below shows that PShape can have an inner cutout created using the beginContour(), endContour() functions. The vertex points specified within those 2 functions will be cut-out of the larger shape that was specified before the beginContour() function. The point numbers correspond to the circled numbers in drawing above.
The image below shows an intricate pattern created using a recursive function and a PShape that has an inner cut-out, contour.