Py5Graphics.load_pixels()#

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

Examples#

example picture for load_pixels()
 1def setup():
 2    g = py5.create_graphics(60, 60)
 3    g.begin_draw()
 4    g.background(255, 0, 0)
 5    g.rect(10, 10, 40, 40)
 6    g.load_pixels()
 7    yellow = "#FF0"
 8    for i in range(len(g.pixels) // 2):
 9        g.pixels[i] = yellow
10    g.update_pixels()
11    g.end_draw()
12
13    py5.background(240)
14    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

Syntax#

load_pixels() -> None

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