Copies pixels from a source image to a region of the canvas.
The first parameter, srcImage
, is the p5.Image object to blend. The source image can be the canvas itself or a p5.Image object. copy()
will scale pixels from the source region if it isn't the same size as the destination 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 the canvas to copy into. (dx, dy)
is the top-left corner of the region. dw
and dh
are the region's width and height.
Examples
Syntax
copy(srcImage, sx, sy, sw, sh, dx, dy, dw, dh)
copy(sx, sy, sw, sh, dx, dy, dw, dh)
Parameters
source image.
x-coordinate of the source's upper-left corner.
y-coordinate of the source's upper-left corner.
source image width.
source image height.
x-coordinate of the destination's upper-left corner.
y-coordinate of the destination's upper-left corner.
destination image width.
destination image height.