-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharcTo.html
More file actions
78 lines (60 loc) · 2.48 KB
/
arcTo.html
File metadata and controls
78 lines (60 loc) · 2.48 KB
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
77
78
<!DOCTYPE html>
<html>
<head>
<title>Canvas 2D Context API Primer</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=1024" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<!--SCRIPTS-->
<script type="text/javascript">
/*
# Context 2d API: arcTo
Draws an arc of a fixed radius between two tangents that are defined by the current point in a path and two additional points.
# Standard Definition.
http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas/#dom-context-2d-arcto
# Function signature
void arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radius);
*/
function draw(){
// Get a reference to the canvas
var canvas = document.getElementById('canvas');
// Get a reference to the drawing context
var ctx = canvas.getContext('2d');
// Drawing tangents
ctx.beginPath();
ctx.lineWidth = "3";
ctx.strokeStyle = "black";
// Horizontal line
ctx.moveTo(80, 100);
ctx.lineTo(240, 100);
// Vertical line
ctx.moveTo(200, 60);
ctx.lineTo(200, 220);
// Draw the lines
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle = "red";
ctx.lineWidth = "5";
ctx.moveTo(120, 100);
// Horizontal line
ctx.lineTo(180, 100); // Draw a horizontal line.
// Draw an arc to connect the horizontal and the vertical line
ctx.arcTo(200, 100, 200, 120, 20);
// Vertical line
ctx.lineTo(200, 180); // Continue with a vertical line of the rectangle.
// Draw the lines
ctx.stroke();
// Use the translate method to move the second example down.
ctx.translate(0, 220);
}
</script>
</head>
<body onload="draw();">
<p>
<a href="index.html">Back to index</a>
</p>
<canvas id="canvas" width="600" height="300">
This browser or document mode doesn't support canvas
</canvas>
</body>
</html>