Py5Graphics

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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 Java class: PGraphics

The following methods and fields are provided:

Pimage

Output

Image

Updated on September 16, 2021 14:31:43pm UTC