forked from play-co/webgl-2d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
37 lines (27 loc) · 930 Bytes
/
example.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
<!DOCTYPE html>
<html>
<head>
<title>WebGL-2D Example</title>
<script src="mjs.js" type="text/javascript"></script>
<script src="webgl-2d.js" type="text/javascript"></script>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", init, false);
var cvs, ctx;
function init() {
cvs = document.getElementById("canvas1");
WebGL2D.enable(cvs); // adds new context "webgl-2d" to cvs
// Easily switch between regular canvas 2d context and webgl-2d
//ctx = cvs.getContext("2d");
ctx = cvs.getContext("webgl-2d");
ctx.fillStyle = "rgba(255, 128, 64, 1.0)";
ctx.translate(-0.2, 0.2);
ctx.rotate(30);
ctx.scale(0.5, 1);
ctx.fillRect(0.1, 0, cvs.width, cvs.height);
}
</script>
</head>
<body>
<canvas id="canvas1" width="400" height="400"></canvas>
</body>
</html>