Gets a pixel or a region of pixels from the canvas.
get()
is easy to use but it's not as fast as pixels. Use pixels to read many pixel values.
The version of get()
with no parameters returns the entire canvas.
The version of get()
with two parameters interprets them as coordinates. It returns an array with the [R, G, B, A]
values of the pixel at the given point.
The version of get()
with four parameters interprets them as coordinates and dimensions. It returns a subsection of the canvas as a p5.Image object. The first two parameters are the coordinates for the upper-left corner of the subsection. The last two parameters are the width and height of the subsection.
Use p5.Image.get() to work directly with p5.Image objects.
Examples
Syntax
get(x, y, w, h)
get()
get(x, y)
Parameters
x-coordinate of the pixel.
y-coordinate of the pixel.
width of the subsection to be returned.
height of the subsection to be returned.