(p5.Image.obj).updatePixels

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.js] (p5.Image.obj).updatePixels

概要

pixels配列や setメソッドによってピクセル単位で設定された内容をイメージに反映させます。

書式

updatePixels(x, y, w, h)
updatePixels

引数

引数名内容備考オプションデフォルト値
x反映領域の左上 x座標
y反映領域の左上 x座標
w反映領域の幅
h反映領域の高さ

戻値

なし

備考

関連

(p5.Image.obj).pixels
(p5.Image.obj).set
(p5.Image.obj).loadPixels