-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
76 lines (67 loc) · 2.59 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0>
<style>
body {
padding: 0;
margin: 0;
background: black;
color:white;
width: fit-content;
margin: auto;
}
canvas {
/* image-rendering: pixelated; */
}
</style>
<script src="p5.js" type="text/javascript"></script>
<script src="sketch.js"></script>
<title>MutantCA</title>
</head>
<body>
<ul>
<li>Click to zoom in.</li>
<li>Arrow keys up/down to speed up/slow down.</li>
</ul>
</body>
<script type="text/javascript">
var attributes = {
alpha: true, // canvas contains an alpha buffer.
depth: false, // drawing buffer has a depth buffer of at least 16 bits.
stencil: false, // drawing buffer has a stencil buffer of at least 8 bits.
antialias: false, // whether or not to perform anti-aliasing.
// premultipliedAlpha: false, // drawing buffer contains colors with pre-multiplied alpha.
preserveDrawingBuffer: true, // buffers will not be cleared
failIfMajorPerformanceCaveat: true
};
window.devicePixelRatio = 1
p5.RendererGL.prototype._initContext = function() {
this.attributes = attributes; // use custom attributes
try {
this.drawingContext = false
|| this.canvas.getContext('webgl2', this.attributes)
|| this.canvas.getContext('webgl', this.attributes)
|| this.canvas.getContext('experimental-webgl', this.attributes)
;
if (this.drawingContext) {
var gl = this.drawingContext;
gl.enable(gl.DEPTH_TEST);
gl.depthFunc(gl.LEQUAL);
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
this._viewport = gl.getParameter(gl.VIEWPORT);
//bounds = canvas.getBoundingClientRect()
//canvas.width = Math.round(bounds.width * window.devicePixelRatio);
//canvas.height = Math.round(bounds.height * window.devicePixelRatio);
//canvas.style.width = (canvas.width / devicePixelRatio) + 'px'
//canvas.style.height = (canvas.height / devicePixelRatio) + 'px'
} else {
throw new Error('Error creating webgl context');
}
} catch (er) {
throw new Error(er);
}
};
</script>
</html>