Py5Shape.begin_shape()#

This method is used to start a custom shape created with the create_shape() function.

Examples#

 1def setup():
 2    global s  # the Py5Shape object
 3    s = py5.create_shape()
 4    s.begin_shape()
 5    s.fill("#F00")
 6    s.no_stroke()
 7    s.vertex(0, 0)
 8    s.vertex(0, 50)
 9    s.vertex(50, 0)
10    s.end_shape()
11
12
13def draw():
14    py5.shape(s, 25, 25)
 1def setup():
 2    global s  # the Py5Shape object
 3    s = py5.create_shape()
 4    with s.begin_shape():
 5        s.fill("#F00")
 6        s.no_stroke()
 7        s.vertex(0, 0)
 8        s.vertex(0, 50)
 9        s.vertex(50, 0)
10
11
12def draw():
13    py5.shape(s, 25, 25)

Description#

This method is used to start a custom shape created with the create_shape() function. It’s always and only used with create_shape().

Drawing commands to a custom shape must always conclude with a call to the Py5Shape.end_shape() method. This method can be used as a context manager to ensure that Py5Shape.end_shape() always gets called, as shown in the second example. Use Py5Shape.begin_closed_shape() to create a context manager that will pass the CLOSE parameter to end_shape(), closing the shape.

Underlying Processing method: PShape.beginShape

Syntax#

begin_shape() -> None
begin_shape(kind: int, /) -> None

Parameters#

  • kind: int - Either POINTS, LINES, TRIANGLES, TRIANGLE_FAN, TRIANGLE_STRIP, QUADS, or QUAD_STRIP

Updated on November 12, 2021 11:30:58am UTC