Py5Graphics#

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

Examples#

def setup():
    global pg
    pg = py5.create_graphics(40, 40)


def draw():
    pg.begin_draw()
    pg.background(100)
    pg.stroke(255)
    pg.line(20, 20, py5.mouse_x, py5.mouse_y)
    pg.end_draw()
    py5.image(pg, 9, 30)
    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 March 06, 2023 02:49:26am UTC