def setup
@img = loadImage("fruit.png")
@img.loadPixels
halfImage = 4 * @img.width * @img.height / 2
for i in (0...halfImage) do
@img.pixels[i + halfImage] = @img.pixels[i]
end
@img.updatePixels
end
def draw
image(@img, 0, 0, width, height)
end
[p5.js] (p5.Image.obj).updatePixels
pixels配列や setメソッドによってピクセル単位で設定された内容をイメージに反映させます。
| 引数名 | 内容 | 備考 | オプション | デフォルト値 |
|---|---|---|---|---|
| x | 反映領域の左上 x座標 | |||
| y | 反映領域の左上 x座標 | |||
| w | 反映領域の幅 | |||
| h | 反映領域の高さ |
なし