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()

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.

Signatures#

update_np_pixels() -> None

Updated on March 06, 2023 02:49:26am UTC