Py5Image.update_np_pixels()

Updates the image with the data in the Py5Image.np_pixels[] array.

Examples

example picture for update_np_pixels()
1
2
3
4
5
6
def setup():
    my_image = py5.load_image("apples.jpg")
    my_image.load_np_pixels()
    my_image.np_pixels[:50, :, :] = my_image.np_pixels[50:100, :, :]
    my_image.update_np_pixels()
    py5.image(my_image, 0, 0)

Description

Updates the image with the data in the Py5Image.np_pixels[] array. Use in conjunction with Py5Image.load_np_pixels(). If you’re only reading pixels from the array, there’s no need to call update_np_pixels() — updating is only necessary to apply changes.

The update_np_pixels() method is similar to Py5Image.update_pixels() in that update_np_pixels() must be called after modifying Py5Image.np_pixels[] just as Py5Image.update_pixels() must be called after modifying Py5Image.pixels[].

Syntax

update_np_pixels() -> None

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