-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
44 lines (39 loc) · 1.18 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Countdown</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/p5.min.js"></script>
<style media="screen"> * { margin: 0 } </style>
</head>
<body>
<script type="text/javascript">
let words = 0
let time = 0
let startTime = null
let dateLimit = null
function now() {
return new Date().getTime()
}
function setup() {
words = prompt('How many words?')
time = prompt('In how many minutes?')
startTime = now()
dateLimit = startTime + (time * 60 * 1000)
createCanvas(windowWidth,windowHeight)
background(51)
}
function draw() {
background(51)
let timeNow = now()
let rectHeight = ((timeNow - startTime) / (dateLimit - startTime) * windowHeight)
let wordRemain = round(words * (dateLimit - timeNow) / (dateLimit - startTime))
fill('blue')
rect(0, rectHeight, windowWidth, windowHeight - rectHeight)
textSize(64)
fill('white')
text(wordRemain, windowWidth / 2, windowHeight / 2)
}
</script>
</body>
</html>