-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshell_resize.html
executable file
·86 lines (77 loc) · 2.71 KB
/
shell_resize.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Eyedrop</title>
<style>
/* Canvas MUST NOT have any border or padding, or mouse coords will be wrong */
#canvas {
display: block;
margin: 10px;
border: 0px none;
background-color: black;
}
#wrapper {
border: solid 2px black;
resize: both;
overflow: hidden;
margin: auto;
width: 660px;
height: 500px;
display: flex;
justify-content: center;
}
#about {
display: block;
margin: auto;
border: 0px none;
width: 660px;
text-align: center;
justify-content: center;
background-color: transparent;
}
</style>
</head>
<body>
<div class="emscripten" id="wrapper">
<canvas width=640 height=480 class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
</div>
<div class="emscripten" id="about">
<br>
<b>Eyedrop Test</b><br>
</div>
<br>
<div class="emscripten" id="about">
<a href="assets/images/blob.png"><img src="assets/images/blob.png" height=128 width=128></a>
</div>
<script type='text/javascript'>
var Module = {
canvas: (function() {
var canvas = document.getElementById('canvas');
var canvasWrapper = document.getElementById('wrapper');
const border_width = 16;
let width;
let height;
setInterval(() => {
const newWidth = canvasWrapper.clientWidth;
const newHeight = canvasWrapper.clientHeight;
if ((width != newWidth - border_width) || (height != newHeight - border_width)) {
width = newWidth - border_width;
height = newHeight - border_width;
canvas.width = width;
canvas.height = height;
window.dispatchEvent(new Event('resize'));
}
}, 100)
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
// application robust, you may want to override this behavior before shipping!
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
return canvas;
})()
};
</script>
{{{ SCRIPT }}}
</body>
</html>