load_np_pixels()

Loads the pixel data of the current display window into the np_pixels[] array.

Examples

example picture for load_np_pixels()
1
2
3
4
5
6
7
def setup():
    my_image = py5.load_image("apples.jpg")
    py5.image(my_image, 0, 0)

    py5.load_np_pixels()
    py5.np_pixels[50:100, :, :] = py5.np_pixels[:50, :, :]
    py5.update_np_pixels()

Description

Loads the pixel data of the current display window into the np_pixels[] array. This method must always be called before reading from or writing to np_pixels[]. Subsequent changes to the display window will not be reflected in np_pixels[] until load_np_pixels() is called again.

The load_np_pixels() method is similar to load_pixels() in that load_np_pixels() must be called before reading from or writing to np_pixels[] just as load_pixels() must be called before reading from or writing to pixels[].

Note that load_np_pixels() will as a side effect call load_pixels(), so if your code needs to read np_pixels[] and pixels[] simultaneously, there is no need for a separate call to load_pixels(). However, be aware that modifying both np_pixels[] and pixels[] simultaneously will likely result in the updates to pixels[] being discarded.

Syntax

load_np_pixels() -> None

Updated on September 11, 2021 16:51:34pm UTC