File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
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 >
You can’t perform that action at this time.
0 commit comments