xxxxxxxxxx
51
let minutes;
let progress
let ticks
let numIncrements;
let mySound;
let input;
function preload() {
soundFormats('mp3');
mySound = loadSound('ding.mp3');
}
function reset() {
progress = 0
ticks = 0
minutes = input.value()
numIncrements = minutes * 60;
}
function setup() {
createCanvas(400, 400)
frameRate(1)
stroke('#00FBE1')
strokeWeight(3)
fill('#222222')
createSpan('Minutes:')
input = createInput("1")
button = createButton('Reset')
button.mousePressed(buttonClicked)
reset()
}
function draw() {
background(0);
text(numIncrements - ticks, 180, 40)
arc(width/2, height/2, 200, 200, 0, progress, PIE)
progress += TWO_PI/numIncrements
ticks++
if (progress > TWO_PI) {
mySound.play()
text('Done!', 180, 350)
noLoop()
}
}
function buttonClicked() {
reset()
loop()
}