forked from jokie88/ordinalpublicgoods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp5js.html
48 lines (40 loc) · 1.26 KB
/
p5js.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
<html>
<script type="module">
import('http://ordinals.com/content/f815bd5c566c6e46de5cdb6ccb3a7043c63deeba61f4234baea84b602b0d4440i0').then(async (fflate) => {
window.p5LoadedPromise = new Promise(async (resolve, reject) => {
try {
const res = await fetch('http://ordinals.com/content/255ce0c5a0d8aca39510da72e604ef8837519028827ba7b7f723b7489f3ec3a4i0');
const base64Data = await res.text();
const compressed = Uint8Array.from(atob(base64Data), c => c.charCodeAt(0));
const inflated = fflate.gunzipSync(compressed);
const p5 = new TextDecoder().decode(inflated);
eval(p5);
resolve(); // Resolve the promise
} catch (err) {
console.error(err);
reject(err); // Reject the promise
}
});
window.p5LoadedPromise.then(() => {
console.log('p5.js has been loaded');
let W = window
W.setup = () => {
createCanvas(400, 400);
console.log("------- yo");
}
W.draw = () => {
console.log("xxx");
background(220);
fill(0)
ellipse(width / 2, height / 2, 20, 20)
}
}).catch((err) => {
console.error('Failed to load p5.js:', err);
});
});
</script>
<script>
</script>
<body>
</body>
</html>