(p5.Graphics.obj).remove

def setup
  pixelDensity(1)
  createCanvas(100, 100)
  stroke(255)
  fill(0)
  # create and draw the background image
  @bg = createGraphics(100, 100)
  @bg.background(200)
  @bg.ellipse(50, 50, 80, 80)
end

def draw
  t = millis / 1000
  # draw the background
  if @bg
    image(@bg, frameCount % 100, 0)
    image(@bg, frameCount % 100 - 100, 0)
  end
  # draw the foreground
  p = P5Vector.fromAngle(t, 35).add(50, 50)
  ellipse(p.x, p.y, 30)
end

def mouseClicked
  # remove the background
  if @bg
    @bg.remove
    @bg = nil
  end
end

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

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

概要

描画用ブジェクトを削除します。

書式

remove

引数

なし

戻値

なし

備考

関連