-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
45 lines (45 loc) · 1.28 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
45
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="glport" content="width=device-width, initial-scale=1.0" />
<title>Gei demo</title>
</head>
<body>
<style>
</style>
<canvas id="canvas"></canvas>
<script type="module">
import { create } from './src/index.js'
const atlasImg = () => {
const canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d')
canvas.width = 128
canvas.height = 32
ctx.fillStyle = '#946ce6'
ctx.strokeStyle = '#5400ff'
ctx.beginPath()
ctx.moveTo(16, 16)
for (let i = 0; i < Math.PI * 2; i += (Math.PI * 2) / 5) {
ctx.lineTo(16 - Math.sin(i) * 16, 16 - Math.cos(i) * 16)
}
ctx.closePath()
ctx.fill()
return canvas
}
const stage = create('#canvas')
const sprite = stage.add(atlasImg())
const sprite2 = stage.add('hj2.png')
function loop() {
sprite.x = Math.random() * stage.gl.canvas.width
sprite.y = Math.random() * stage.gl.canvas.height
sprite2.x = Math.random() * stage.gl.canvas.width
sprite2.y = Math.random() * stage.gl.canvas.height
stage.clear(0.9, 0.9, 1, 1)
stage.draw()
requestAnimationFrame(loop)
}
loop()
</script>
</body>
</html>