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

beginContour()

Examples
PShape s;

void setup() {
  size(100, 100);

  // 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();
}

void draw() {
  background(52);
  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.beginContour()
Parameters
sh PShape: any variable of type PShape
Returnsvoid
RelatedendContour()
Updated on January 21, 2019 10:05:12am EST

Creative Commons License