size(100, 100, P2D) translate(50, 50) stroke(255, 0, 0) beginShape() # Exterior part of shape vertex(-40, -40) vertex(40, -40) vertex(40, 40) vertex(-40, 40) # Interior part of shape beginContour() vertex(-20, -20) vertex(20, -20) vertex(20, 20) vertex(-20, 20) endContour() endShape(CLOSE)
Use the beginContour() and endContour() function to create negative shapes within shapes. For instance, the center of the letter 'O'. beginContour() begins recording vertices for the shape and endContour() stops recording. These functions can only be within a beginShape()/endShape() pair and they only work with the P2D and P3D renderers.
Transformations such as translate(), rotate(), and scale() do not work within a beginContour()/endContour() pair. It is also not possible to use other shapes, such as ellipse() or rect() within.
Updated on Mon Sep 21 15:53:24 2020.
If you see any errors or have comments, please let us know.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License