pixels array contains the values for all the pixels in the display window.
1def setup(): 2 pink = "#F6C" 3 py5.load_pixels() 4 for i in range(0, (py5.width*py5.height//2) - py5.width//2): 5 py5.pixels[i] = pink 6 7 py5.update_pixels()
pixels array contains the values for all the pixels in the display window. These values are of the color datatype. This array is defined by the size of the display window. For example, if the window is 100 x 100 pixels, there will be 10,000 values and if the window is 200 x 300 pixels, there will be 60,000 values. When the pixel density is set to higher than 1 with the pixel_density() function, these values will change. See the reference for pixel_width or pixel_height for more information.
Before accessing this array, the data must loaded with the load_pixels() function. Failure to do so may result in a Java
NullPointerException. Subsequent changes to the display window will not be reflected in
pixels until load_pixels() is called again. After
pixels has been modified, the update_pixels() function must be run to update the content of the display window.
Underlying Processing field: pixels
Updated on November 12, 2021 11:30:58am UTC