Py5Graphics.update_np_pixels()

Updates the Py5Graphics drawing surface with the data in the Py5Graphics.np_pixels[] array.

Examples

example picture for update_np_pixels()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
def setup():
    g = py5.create_graphics(80, 80)
    g.begin_draw()
    g.background(255)
    g.rect(10, 10, 60, 60)
    g.load_np_pixels()
    g.np_pixels[:, 40:, 1:] = [255, 0, 0]
    g.update_np_pixels()
    g.end_draw()
    py5.image(g, 10, 10)

Description

Updates the Py5Graphics drawing surface with the data in the Py5Graphics.np_pixels[] array. Use in conjunction with Py5Graphics.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. Working with Py5Graphics.np_pixels[] can only be done between calls to Py5Graphics.begin_draw() and Py5Graphics.end_draw().

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

This method is the same as update_np_pixels() but linked to a Py5Graphics object.

Syntax

update_np_pixels() -> None

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