Py5Shape.begin_closed_shape()#

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

Examples#

 1def setup():
 2    global s  # the Py5Shape object
 3    s = py5.create_shape()
 4    with s.begin_closed_shape():
 5        s.stroke_weight(5)
 6        s.no_fill()
 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 closed shape created with the create_shape() function. It’s always and only used with create_shape().

This method should only be used as a context manager, as shown in the example. When used as a context manager, this will ensure that Py5Shape.end_shape() always gets called, just like when using Py5Shape.begin_shape() as a context manager. The difference is that when exiting, the parameter CLOSE will be passed to Py5Shape.end_shape(), connecting the last vertex to the first. This will close the shape. If this method were to be used not as a context manager, it won’t be able to close the shape by making the call to Py5Shape.end_shape().

Underlying Processing method: PShape.beginShape

Syntax#

begin_closed_shape() -> None
begin_closed_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