-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.html
More file actions
40 lines (31 loc) · 813 Bytes
/
example.html
File metadata and controls
40 lines (31 loc) · 813 Bytes
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
<html>
<head>
<title>Rotate</title>
</head>
<body>
<script src="build/build.js"></script>
<p><input type="range" min=0 max=360 value=0></p>
<canvas width=300 height=300></canvas>
<script>
var rotate = require('rotate');
var input = document.querySelector('input');
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('2d');
function draw(deg) {
canvas.width = canvas.width;
ctx.strokeRect(0, 0, 300, 300);
ctx.save();
ctx.translate(25, 25);
rotate(ctx, { degrees: deg, x: 25, y: 25 });
ctx.fillRect(0, 0, 50, 50);
ctx.fillStyle = 'red';
ctx.restore();
ctx.strokeRect(50, 50, 50, 50);
}
draw(0);
input.onchange = function(e){
draw(input.value);
};
</script>
</body>
</html>