Skip to content

Commit d9bee09

Browse files
fix: Double check newest changes work for #443
And added it as an example, it is pretty.
1 parent 4aa08ca commit d9bee09

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

examples/slow-fade.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<html>
2+
<title>Slow Fade</title>
3+
<body>
4+
<h1>Slow Fade</h1>
5+
<div>
6+
<canvas id="c" />
7+
</div>
8+
</body>
9+
<script src="../bin/gpu-browser.js"></script>
10+
<script>
11+
const canvas = document.getElementById("c");
12+
const gpu = new GPU({
13+
canvas: canvas,
14+
mode: "gpu"
15+
});
16+
const dim = 512;
17+
const kernel = gpu.createKernel(
18+
function(x) {
19+
this.color(
20+
(x * (this.thread.y + this.thread.x)) / 1024.0,
21+
(x * (this.thread.y * this.thread.x)) / (1024.0 * 1024.0),
22+
(x * (this.thread.y * 2 * this.thread.x)) / (1024.0 * 2),
23+
1
24+
);
25+
},
26+
{
27+
output: [dim, dim],
28+
graphical: true
29+
}
30+
);
31+
32+
let param = 0.0;
33+
const doDraw = () => {
34+
kernel(param);
35+
param += 0.001;
36+
window.requestAnimationFrame(doDraw);
37+
};
38+
39+
window.requestAnimationFrame(doDraw);
40+
</script>
41+
</html>

0 commit comments

Comments
 (0)