参考 copy()

copy()

Copies pixels from a source image to this image.

The first parameter, srcImage, is an optional p5.Image object to copy. If a source image isn't passed, then img.copy() can copy a region of this image to another region.

The next four parameters, sx, sy, sw, and sh determine the region to copy from the source image. (sx, sy) is the top-left corner of the region. sw and sh are the region's width and height.

The next four parameters, dx, dy, dw, and dh determine the region of this image to copy into. (dx, dy) is the top-left corner of the region. dw and dh are the region's width and height.

Calling img.copy() will scale pixels from the source region if it isn't the same size as the destination region.

示例

语法

copy(srcImage, sx, sy, sw, sh, dx, dy, dw, dh)
copy(sx, sy, sw, sh, dx, dy, dw, dh)

参数

srcImage
p5.Image|p5.Element:

source image.

sx
Integer:

x-coordinate of the source's upper-left corner.

sy
Integer:

y-coordinate of the source's upper-left corner.

sw
Integer:

source image width.

sh
Integer:

source image height.

dx
Integer:

x-coordinate of the destination's upper-left corner.

dy
Integer:

y-coordinate of the destination's upper-left corner.

dw
Integer:

destination image width.

dh
Integer:

destination image height.

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

相关参考