Py5Image.update_pixels()

Updates the image with the data in its Py5Image.pixels[] array.

Examples

example picture for update_pixels()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
def setup():
    global my_image
    global half_image
    half_image = py5.width * py5.height//2
    my_image = py5.load_image("apples.jpg")
    my_image.load_pixels()
    for i in range(0, half_image):
        my_image.pixels[i+half_image] = my_image.pixels[i]

    my_image.update_pixels()


def draw():
    py5.image(my_image, 0, 0)

Description

Updates the image with the data in its Py5Image.pixels[] array. Use in conjunction with Py5Image.load_pixels(). If you’re only reading pixels from the array, there’s no need to call update_pixels().

Underlying Java method: PImage.updatePixels

Syntax

update_pixels() -> None
update_pixels(x: int, y: int, w: int, h: int, /) -> None

Parameters

  • h: int - height

  • w: int - width

  • x: int - x-coordinate of the upper-left corner

  • y: int - y-coordinate of the upper-left corner

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