def setup
createCanvas(100, 100);
changeBG = Proc.new {
if isLooping
@colBG = color(rand(255), rand(255), rand(255))
@colFill = color(rand(255), rand(255), rand(255))
end
}
button = createButton('Colorize if loop')
button.position(0, 120)
button.mousePressed(changeBG)
button.position(0, 150)
checkbox = createCheckbox('loop', true)
checkLoop = Proc.new {
if checkbox.checked()
loop
else
noLoop
end
}
checkbox.changed(checkLoop)
@colBG = color(0)
@colFill = color(255)
end
def draw
background(@colBG)
fill(@colFill);
ellipse(frameCount % width, height / 2, 50)
end