在画布上绘制两条路径;红色和蓝色:
JavaScript:
</>code
- var c=document.getElementById("myCanvas");
- var ctx=c.getContext("2d");
ctx.beginPath();
- ctx.lineWidth="5";
- ctx.strokeStyle="red"; // 红色路径
- ctx.moveTo(0,75);
- ctx.lineTo(250,75);
- ctx.stroke(); // 进行绘制
ctx.beginPath();
- ctx.strokeStyle="blue"; // 蓝色路径
- ctx.moveTo(50,0);
- ctx.lineTo(150,130);
- ctx.stroke(); // 进行绘制
Internet Explorer 9、Firefox、Opera、Chrome 以及 Safari 支持 beginPath() 方法。
注释:Internet Explorer 8 或更早的浏览器不支持 <canvas> 元素。
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号