4.canvas-路径
var can=document.getElementById("mycanvas"); var draw=can.getContext("2d"); // 开始一个路径 draw.beginPath(); // 设置线的粗细 draw.lineWidth="5"; //设置线的颜色 draw.strokeStyle="green"; // 线的起点 draw.moveTo(0,75); //线的终点 draw.lineTo(250,75); // 开始绘制路径 draw.stroke(); //开始另一个路径 draw.beginPath(); // 设置线的粗细 draw.lineWidth="5"; draw.strokeStyle="purple"; draw.moveTo(25,05); draw.lineTo(35,25); draw.stroke();
效果: