Py5Graphics#

Main graphics and rendering context, as well as the base API implementation for processing “core”.

Examples#

 1def setup():
 2    global pg
 3    pg = py5.create_graphics(40, 40)
 4
 5
 6def draw():
 7    pg.begin_draw()
 8    pg.background(100)
 9    pg.stroke(255)
10    pg.line(20, 20, py5.mouse_x, py5.mouse_y)
11    pg.end_draw()
12    py5.image(pg, 9, 30)
13    py5.image(pg, 51, 30)

Description#

Main graphics and rendering context, as well as the base API implementation for processing “core”. Use this class if you need to draw into an off-screen graphics buffer. A Py5Graphics object can be constructed with the create_graphics() function. The Py5Graphics.begin_draw() and Py5Graphics.end_draw() methods (see example) are necessary to set up the buffer and to finalize it. The fields and methods for this class are extensive.

It is critically important that calls to this object’s drawing methods are only used between Py5Graphics.begin_draw() and Py5Graphics.end_draw(). Forgetting to call Py5Graphics.begin_draw() will likely result in an ugly and unhelpful Java exception.

To create a new graphics context, use the create_graphics() function. Do not use the syntax Py5Graphics().

Underlying Processing class: PGraphics

The following methods and fields are provided:

Pgraphics#

Method#

Pimage#

Color#

Creating / Reading#

Setting#

Environment#

Image#

Loading / Displaying#

Pixels#

Textures#

Lights & Camera#

Camera#

Coordinates#

Lights#

Material Properties#

Output#

Files#

Image#

Rendering#

Shaders#

Shape#

2D Primitives#

3D Primitives#

Attributes#

Curves#

Loading / Displaying#

Vertex#

Structure#

Transform#

Typography#

Attributes#

Loading / Displaying#

Metrics#

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