-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
64 lines (63 loc) · 2.56 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<canvas></canvas>
<script>
(WebAssembly
.compile(Uint8Array.of(
// canvas.wast file compiled with https://cdn.rawgit.com/WebAssembly/wabt/013802ca01035365e2459c70f0508481393ac075/demo/wast2wasm/
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x19, 0x05, 0x60,
0x00, 0x00, 0x60, 0x02, 0x7c, 0x7c, 0x00, 0x60, 0x04, 0x7c, 0x7c, 0x7c,
0x7c, 0x00, 0x60, 0x01, 0x7c, 0x01, 0x7c, 0x60, 0x01, 0x7c, 0x00, 0x02,
0x46, 0x05, 0x03, 0x63, 0x74, 0x78, 0x09, 0x62, 0x65, 0x67, 0x69, 0x6e,
0x50, 0x61, 0x74, 0x68, 0x00, 0x00, 0x03, 0x63, 0x74, 0x78, 0x06, 0x73,
0x74, 0x72, 0x6f, 0x6b, 0x65, 0x00, 0x00, 0x03, 0x63, 0x74, 0x78, 0x06,
0x6c, 0x69, 0x6e, 0x65, 0x54, 0x6f, 0x00, 0x01, 0x03, 0x63, 0x74, 0x78,
0x09, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x52, 0x65, 0x63, 0x74, 0x00, 0x02,
0x04, 0x4d, 0x61, 0x74, 0x68, 0x03, 0x73, 0x69, 0x6e, 0x00, 0x03, 0x03,
0x02, 0x01, 0x04, 0x07, 0x08, 0x01, 0x04, 0x64, 0x72, 0x61, 0x77, 0x00,
0x05, 0x0a, 0x9a, 0x01, 0x01, 0x97, 0x01, 0x02, 0x01, 0x7c, 0x01, 0x7f,
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00,
0xc0, 0x72, 0x40, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x62, 0x40,
0x10, 0x03, 0x10, 0x00, 0x41, 0xb8, 0x17, 0x21, 0x02, 0x03, 0x40, 0x20,
0x02, 0xb8, 0x20, 0x00, 0xa0, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
0x8f, 0x40, 0xa3, 0x22, 0x01, 0x10, 0x04, 0x44, 0x00, 0x00, 0x00, 0x00,
0x00, 0xa0, 0x62, 0x40, 0xa2, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x62, 0x40, 0xa0, 0x20, 0x01, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xfc, 0x3f, 0xa2, 0x44, 0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0xf9, 0x3f,
0xa0, 0x10, 0x04, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x52, 0x40,
0xa2, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x52, 0x40, 0xa0, 0x10,
0x02, 0x20, 0x02, 0x41, 0x1e, 0x6b, 0x22, 0x02, 0x0d, 0x00, 0x0b, 0x10,
0x01, 0x0b
))
.then(module => {
const ctx = document.querySelector('canvas').getContext('2d');
return WebAssembly.instantiate(
module,
{
ctx: {
// Functions imported into wasm are called with undefined as this,
// so we have to bind them (wah!)
clearRect: ctx.clearRect.bind(ctx),
lineTo: ctx.lineTo.bind(ctx),
stroke: ctx.stroke.bind(ctx),
beginPath: ctx.beginPath.bind(ctx),
},
Math
}
)
})
.then(instance => {
(function frame() {
instance.exports.draw(Date.now());
requestAnimationFrame(frame)
})();
})
);
</script>
</body>
</html>