(p5.Image.obj).copy

def setup
  img = loadImage("fruit.png")
  x = img.width / 2
  y = img.height / 2
  img.copy(img, 0, 0, x, y, 25, 25, x, y)
  image(img, 0, 0)
end

p5.jsリファレンス(参考情報)

[p5.js] (p5.Image.obj).copy

概要

イメージの指定領域をイメージの別の領域にコピーします。

書式

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

引数

引数名内容備考オプションデフォルト値
srcImagep5.Imageオブジェクト
sxコピー元の領域の左上 x座標コピー元
syコピー元の領域の左上 y座標
swコピー元の領域の幅
shコピー元の領域の高さ
dxコピー先の領域の左上 x座標コピー先
dyコピー先の領域の左上 y座標
dwコピー先の領域の幅
dhコピー先の領域の高さ

戻値

なし

備考

・コピー元が指定されていない場合、コピー元はイメージ自身となります。

・コピー元とコピー先とで領域サイズが異なる場合、
 コピー先の領域サイズの合わせてコピー元の領域サイズが自動的に変更されます。

関連

copy