-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
47 lines (37 loc) · 904 Bytes
/
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
45
46
47
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="500" height="500" style="border:1px solid #d3d3d3;">
</canvas>
<script>
let c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
function drawRect(x, y, r){
ctx.fillStyle = `rgb(${r},0,0)`;
ctx.fillRect(x, y, 5, 500);
}
function random100Arc(){
for( let i = 0 ; i < 100 ; i++ ){
drawArc();
}
}
function getRandomNumber(n){
let x = Math.random()*n;
return Math.round(x);
}
function getRandomColor(){
let r = getRandomNumber(255);
let g = getRandomNumber(255);
let b = getRandomNumber(255);
return `rgb(${r},0,0)`;
}
function drawArc() {
ctx.beginPath();
ctx.fillStyle = getRandomColor();
ctx.arc(getRandomNumber(500), getRandomNumber(500), getRandomNumber(100) +40, 0, 2 * Math.PI);
ctx.fill();
}
setInterval(random100Arc, 10);
</script>
</body>
</html>