-
Notifications
You must be signed in to change notification settings - Fork 0
/
line.html
49 lines (33 loc) · 868 Bytes
/
line.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
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
#cvs{border: 1px solid red;}
</style>
</head>
<body>
<canvas id="cvs" width="500" height="500"></canvas>
<script>
var cvs=document.getElementById("cvs");
if(cvs.getContext){
var ctx=cvs.getContext('2d');
//如果绘制多条路径必须使用beginPath做分隔
ctx.beginPath();
ctx.moveTo(100,100);//起点
ctx.lineTo(150,150);//从上一条路径 链接到当前的路径
ctx.lineTo(50,150);
ctx.lineTo(100,100);
ctx.stroke();//描线
ctx.beginPath();
ctx.moveTo(300,300);
ctx.lineTo(350,350);
ctx.lineTo(350,300);
ctx.fill();
ctx.stroke();
}else{
}
</script>
</body>
</html>