Py5Graphics.begin_closed_shape()#

This method is used to start a custom closed shape.

Examples#

example picture for begin_closed_shape()
 1def setup():
 2    py5.size(100, 100, py5.P2D)
 3
 4    g = py5.create_graphics(60, 60, py5.P2D)
 5    with g.begin_draw():
 6        with g.begin_closed_shape():
 7            g.vertex(10, 10)
 8            g.vertex(50, 10)
 9            g.vertex(50, 50)
10            g.vertex(10, 50)
11            with g.begin_contour():
12                g.vertex(20, 20)
13                g.vertex(20, 40)
14                g.vertex(40, 40)
15                g.vertex(40, 20)
16
17    py5.image(g, 0, 0)
18    py5.image(g, 25, 25)

Description#

This method is used to start a custom closed 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 Py5Graphics.end_shape() always gets called, just like when using Py5Graphics.begin_shape() as a context manager. The difference is that when exiting, the parameter CLOSE will be passed to Py5Graphics.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 Py5Graphics.end_shape().

This method is the same as begin_closed_shape() but linked to a Py5Graphics object.

Underlying Processing method: PGraphics.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