案例:html/html5 案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3;">
6
Your browser does not support the HTML5 canvas tag.
7
</canvas>
8
9
<script>
10
11
var c=document.getElementById("myCanvas");
12
var ctx=c.getContext("2d");
13
14
ctx.beginPath();              
15
ctx.lineWidth="5";
16
ctx.strokeStyle="red";  // 绿色路径
17
ctx.moveTo(0,75);
18
ctx.lineTo(250,75);
19
ctx.stroke();  // 进行绘制
20
21
ctx.beginPath();
22
ctx.strokeStyle="blue";  // 紫色路径
23
ctx.moveTo(50,0);
24
ctx.lineTo(150,130);            
25
ctx.stroke();  // 进行绘制
26
27
</script>
28
29
</body>
30
</html>
31