Gets a pixel or a region of pixels from the image.
img.get()
is easy to use but it's not as fast as img.pixels. Use img.pixels to read many pixel values.
The version of img.get()
with no parameters returns the entire image.
The version of img.get()
with two parameters, as in img.get(10, 20)
, 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 img.get()
with four parameters, as in img,get(10, 20, 50, 90)
, interprets them as coordinates and dimensions. The first two parameters are the coordinates of the upper-left corner of the subsection. The last two parameters are the width and height of the subsection. It returns a subsection of the canvas in a new p5.Image object.
Use img.get()
instead of get() to work directly with images.
Ejemplos
Sintaxis
get(x, y, w, h)
get()
get(x, y)
Parámetros
x-coordinate of the pixel.
y-coordinate of the pixel.
width of the subsection to be returned.
height of the subsection to be returned.