Skip to content

Commit 7d324b7

Browse files
committed
Logo sketch: enable WebGL alpha for transparency
1 parent 5582ab2 commit 7d324b7

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

assets/logo_sketch.html

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
<!DOCTYPE html>
22
<html><head>
3-
<style>*{margin:0;padding:0;overflow:hidden}body{background:#fff}canvas{display:block}</style>
3+
<style>*{margin:0;padding:0;overflow:hidden}body{background:transparent}canvas{display:block}</style>
44
</head><body>
55
<canvas id="canvas"></canvas>
66
<script>
7-
window.Module={canvas:document.getElementById('canvas'),print:console.log,printErr:console.warn};
7+
var canvas = document.getElementById('canvas');
8+
// Enable alpha on WebGL context
9+
var _origGetContext = canvas.getContext.bind(canvas);
10+
canvas.getContext = function(type, attrs) {
11+
if (type === 'webgl' || type === 'webgl2') {
12+
attrs = Object.assign({}, attrs || {}, {alpha: true, premultipliedAlpha: false});
13+
}
14+
return _origGetContext(type, attrs);
15+
};
16+
window.Module = {
17+
canvas: canvas,
18+
print: console.log,
19+
printErr: console.warn
20+
};
821
window.addEventListener('message', function(e) {
922
if (e.data === 'dark') document.body.style.background = '#1a1a2e';
10-
if (e.data === 'light') document.body.style.background = '#fff';
23+
if (e.data === 'light') document.body.style.background = 'transparent';
1124
});
1225
</script>
1326
<script src="logo_sketch.js"></script>

0 commit comments

Comments
 (0)