Py5Graphics.load_pixels()
Contents
Py5Graphics.load_pixels()¶
Loads the pixel data of the current Py5Graphics drawing surface into the Py5Graphics.pixels[] array.
Examples¶

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