Reference updatePixels()

updatePixels()

Updates the canvas with the RGBA values in the img.pixels array.

img.updatePixels() only needs to be called after changing values in the img.pixels array. Such changes can be made directly after calling img.loadPixels() or by calling img.set().

The optional parameters x, y, width, and height define a subsection of the image to update. Doing so can improve performance in some cases.

If the image was loaded from a GIF, then calling img.updatePixels() will update the pixels in current frame.

Examples

Syntax

updatePixels(x, y, w, h)
updatePixels()

Parameters

x
Integer:

x-coordinate of the upper-left corner of the subsection to update.

y
Integer:

y-coordinate of the upper-left corner of the subsection to update.

w
Integer:

width of the subsection to update.

h
Integer:

height of the subsection to update.

Notice any errors or typos? Please let us know. Please feel free to edit src/image/p5.Image.js and open a pull request!

Related References