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.Graphics.obj).remove
描画用ブジェクトを削除します。
なし
なし