File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 12
12
13
13
var canvas = document . querySelector ( 'canvas' ) ;
14
14
15
+ function resizeCanvas ( ) {
16
+ canvas . style . width = window . innerWidth + 'px' ;
17
+ canvas . style . height = window . innerHeight + 'px' ;
18
+ if ( ! canvas . isOffscreen ) {
19
+ canvas . width = Math . round ( window . innerWidth * window . devicePixelRatio ) ;
20
+ canvas . height = Math . round ( window . innerHeight * window . devicePixelRatio ) ;
21
+ }
22
+ if ( window . resizeCallback ) {
23
+ getWasmTableEntry ( window . resizeCallback ) ( ) ;
24
+ }
25
+ }
26
+
27
+ if ( ! location . search . includes ( 'windowed' ) ) {
28
+ resizeCanvas ( ) ;
29
+ onresize = resizeCanvas ;
30
+ }
31
+
32
+ if ( location . search . includes ( 'thumbnail' ) ) {
33
+ // Save the canvas to file when clicking on it.
34
+ // Not working: https://bugs.chromium.org/p/chromium/issues/detail?id=1175665
35
+ canvas . onclick = function ( ) {
36
+ var img = canvas . toDataURL ( "image/png" ) ;
37
+ var a = document . createElement ( 'a' ) ;
38
+ a . href = img ;
39
+ a . download = 'canvas.png' ;
40
+ a . click ( ) ;
41
+ }
42
+ }
43
+
44
+ #if WASM == 2
45
+ var supportsWasm = window . WebAssembly && location . search . indexOf ( '_rwasm=0' ) < 0 ;
46
+ #endif
47
+
15
48
// Depending on the build flags that one uses, different files need to be downloaded
16
49
// to load the compiled page. The right set of files will be expanded to be downloaded
17
50
// via the directive below.
You can’t perform that action at this time.
0 commit comments