Py5Graphics.load_pixels()

Py5Graphics.load_pixels()#

Loads the pixel data of the current Py5Graphics drawing surface into the Py5Graphics.pixels[] array.

Examples#

example picture for load_pixels()

def setup():
    g = py5.create_graphics(60, 60)
    g.begin_draw()
    g.background(255, 0, 0)
    g.rect(10, 10, 40, 40)
    g.load_pixels()
    yellow = "#FF0"
    for i in range(len(g.pixels) // 2):
        g.pixels[i] = yellow
    g.update_pixels()
    g.end_draw()

    py5.background(240)
    py5.image(g, 20, 20)

Description#

Loads the pixel data of the current Py5Graphics drawing surface into the Py5Graphics.pixels[] array. This function must always be called before reading from or writing to Py5Graphics.pixels[]. Subsequent changes to the Py5Graphics drawing surface will not be reflected in Py5Graphics.pixels[] until load_pixels() is called again.

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

Underlying Processing method: PGraphics.loadPixels

Signatures#

load_pixels() -> None

Updated on March 06, 2023 02:49:26am UTC