html
html
1
2
3
4
5
6
7
8
9
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<canvas></canvas>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
body {
margin: 0;
}
canvas {
position: absolute;
width: 100vw;
height: 100vh;
}
Enter to Rename, Shift+Enter to Preview
js
js
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
const w = innerWidth, h = innerHeight
let ctx
const {random, sin, cos, PI,
hypot, asin, sign} = Math
const birdWidth = 12
const birdHeight = 6
const birdSpeed = 120
const birdCount = 30
const minDistance = 48
const birds = []
onload = () => {
const cvs = document.querySelector('canvas')
cvs.width = w
cvs.height = h
ctx = cvs.getContext('2d')
ctx.strokeStyle = '#9ec5ff'
ctx.fillStyle = '#271441'
for(let i = 0; i < birdCount; i++)
birds.push(new Bird)
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run