- Processing
- p5.js
- Processing.py
- Processing for Android
- Processing for Pi

- Processing Foundation

This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

Class | PShape
Name | ### endContour()
Examples |
    PShape s;

    void setup() {
      size(200, 200, P2D);

      // Make a shape
      s = createShape();
      s.beginShape();
      //s.noStroke();

      // Exterior part of shape
      s.vertex(-50,-50);
      s.vertex(50,-50);
      s.vertex(50,50);
      s.vertex(-50,50);

      // Interior part of shape
      s.beginContour();
      s.vertex(-20,-20);
      s.vertex(-20,20);
      s.vertex(20,20);
      s.vertex(20,-20);
      s.endContour();

      // Finish off shape
      s.endShape(CLOSE);
    }

    void draw() {
      background(204);
      translate(width/2, height/2);
      s.rotate(0.01);
      shape(s);
    }
Description | The beginContour() and endContour() methods make it possible to define shapes with other shapes cut out of them. For example, the inside of a letter 'O'. These two functions are always used together, you'll never use one without the other. Between them, define the geometry you want to create. As you'll see when you run the example above, the second smaller shape is cut out of the first larger shape. The exterior shape and the interior contour must wind in opposite directions. This means that if the points of the geometry for the exterior shape are described in a clockwise order, the points on the interior shape are defined in a counterclockwise order.
Syntax |
    sh.endContour()
Parameters |
sh | PShape: any variable of type PShape
Returns | void
Related | beginContour()

Updated on January 1, 2021 03:38:09am EST
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.