p5.js | beginContour() Function
The beginContour() function in p5.js is used to create negative shapes in other shapes, that is, it can be used to remove a portion of a shape with the given vertices. This function starts the recording of the shape that has to be removed. It is used with the endContour() function that stops the recording of the vertices.
The vertices of the interior shape have to be defined in the opposite direction to that of the exterior one. If the exterior shape has the vertices defined in the clockwise order, then the interior shape has to be defined in the counter-clockwise direction.
This function can only be used inside the beginShape() or endShape() function. Transformations like translate(), rotate() and scale() do not work with shapes and contours.
Parameters: This function accepts no parameters.
The program below illustrates the beginContour() function in p5.js:
Online editor: https://editor.p5js.org/
Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/