Py5Shape.end_contour()

Py5Shape.end_contour()#

Use the Py5Shape.begin_contour() and end_contour() methods to create negative shapes within a Py5Shape object such as the center of the letter ‘O’.

Examples#

example picture for end_contour()

def setup():
    py5.size(100, 100, py5.P2D)
    s = py5.create_shape()
    s.begin_shape()
    # exterior part of shape, clockwise winding
    s.vertex(20, 20)
    s.vertex(80, 20)
    s.vertex(80, 80)
    s.vertex(20, 80)
    # interior part of shape, counter-clockwise winding
    s.begin_contour()
    s.vertex(40, 40)
    s.vertex(40, 60)
    s.vertex(60, 60)
    s.vertex(60, 40)
    s.end_contour()
    s.end_shape(py5.CLOSE)
    py5.shape(s)

Description#

Use the Py5Shape.begin_contour() and end_contour() methods to create negative shapes within a Py5Shape object such as the center of the letter ‘O’. The Py5Shape.begin_contour() method begins recording vertices for the shape and end_contour() stops recording. The vertices that define a negative shape must “wind” in the opposite direction from the exterior shape. First draw vertices for the exterior shape in clockwise order, then for internal shapes, draw vertices counterclockwise.

These methods can only be used within a Py5Shape.begin_shape() & Py5Shape.end_shape() pair and transformations such as Py5Shape.translate(), Py5Shape.rotate(), and Py5Shape.scale() do not work within a Py5Shape.begin_contour() & end_contour() pair. It is also not possible to use other shapes, such as ellipse() or rect() within.

Underlying Processing method: PShape.endContour

Signatures#

end_contour() -> None

Updated on March 06, 2023 02:49:26am UTC