(p5graphics).reset

def setup
  createCanvas(100, 100)
  background(0)
  @pg = createGraphics(50, 100)
  @pg.fill(0)
  frameRate(5)
end

def draw
  image(@pg, width / 2, 0)
  @pg.background(255)
  rect(0, 0, width / 2, 5)
  @pg.rect(0, 0, width / 2, 5)
  translate(0, 5, 0)
  @pg.translate(0, 5, 0)
end

def mouseClicked
  # if you click you will see that
  # 'reset' resets the translate back to the initial state
  # of the Graphics object
  @pg.reset
end

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

[p5.js] (p5.Graphics.obj).reset

概要

座標変換の設定など、描画用オブジェクト(グラフィックバッファ)に対して自動的にクリアされない値をリセットします。

書式

obj.reset

引数

なし

戻値

obj (メソッドを呼び出した p5graphicsオブジェクト自身)

備考

関連