参考 get()

get()

Gets a pixel or a region of pixels from the framebuffer.

myBuffer.get() is easy to use but it's not as fast as myBuffer.pixels. Use myBuffer.pixels to read many pixel values.

The version of myBuffer.get() with no parameters returns the entire framebuffer as a a p5.Image object.

The version of myBuffer.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 myBuffer.get() with four parameters interprets them as coordinates and dimensions. It returns a subsection of the framebuffer 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.

语法

get(x, y, w, h)
get()
get(x, y)

参数

x
Number:

x-coordinate of the pixel. Defaults to 0.

y
Number:

y-coordinate of the pixel. Defaults to 0.

w
Number:

width of the subsection to be returned.

h
Number:

height of the subsection to be returned.

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

相关参考