update_pixels()

update_pixels()#

Updates the display window with the data in the pixels[] array.

Examples#

example picture for update_pixels()

def setup():
    img = py5.load_image("rockies.jpg")
    py5.image(img, 0, 0)
    half_image = img.width * img.height//2
    py5.load_pixels()
    for i in range(0, half_image):
        py5.pixels[i+half_image] = py5.pixels[i]
    
    py5.update_pixels()

Description#

Updates the display window with the data in the pixels[] array. Use in conjunction with load_pixels(). If you’re only reading pixels from the array, there’s no need to call update_pixels() — updating is only necessary to apply changes.

Underlying Processing method: updatePixels

Signatures#

update_pixels() -> None

update_pixels(
    x1: int,  # x-coordinate of the upper-left corner
    y1: int,  # y-coordinate of the upper-left corner
    x2: int,  # width of the region
    y2: int,  # height of the region
    /,
) -> None

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