-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2DTransformExample01.htm
executable file
·46 lines (35 loc) · 1.39 KB
/
2DTransformExample01.htm
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
<!DOCTYPE html>
<html>
<head>
<title>Canvas Transform Example</title>
</head>
<body>
<canvas id="drawing" width="200" height="200">Your browser doesn't support the canvas tag.</canvas>
<script type="text/javascript">
window.onload = function(){
var drawing = document.getElementById("drawing");
//make sure <canvas> is completely supported
if (drawing.getContext){
var context = drawing.getContext("2d");
//start the path
context.beginPath();
//draw outer circle
context.arc(100, 100, 99, 0, 2 * Math.PI, false);
//draw inner circle
context.moveTo(194, 100);
context.arc(100, 100, 94, 0, 2 * Math.PI, false);
//move center to (100,100)
context.translate(100, 100);
context.rotate(1);
//draw minute hand
context.moveTo(0,0);
context.lineTo(0, -85);
//draw hour hand
context.moveTo(0, 0);
context.lineTo(-65, 0);
context.stroke();
}
};
</script>
</body>
</html>