var oCa=document.getElementById('canvas');
var oEv=oCa.getContext('2d');//设置绘图环境
var w=oCa.width=window.innerWidth;
var h=oCa.height=window.innerHeight;
//直线画法
oEv.beginPath();//开的路径
oEv.moveTo(100,100);//将触笔移动到这个位置
oEv.lineTo(300,300);//绘制到哪个点坐标
oEv.strokeStyle='red';
oEv.lineWidth=14;
oEv.closePath();//闭合路径
oEv.stroke();//调用触笔方法(canvas)
//圆的画法
oEv.beginPath();//画圆
oEv.arc(300,300,200,0,2*Math.PI,false);
oEv.strokeStyle='green';
oEv.closePath();
oEv.stroke();
//正方体的画法
oEv.beginPath();
oEv.fillStyle='pink';
oEv.fillRect(300,300,350,350);
oEv.closePath();
oEv.stroke();
var oEv=oCa.getContext('2d');//设置绘图环境
var w=oCa.width=window.innerWidth;
var h=oCa.height=window.innerHeight;
//直线画法
oEv.beginPath();//开的路径
oEv.moveTo(100,100);//将触笔移动到这个位置
oEv.lineTo(300,300);//绘制到哪个点坐标
oEv.strokeStyle='red';
oEv.lineWidth=14;
oEv.closePath();//闭合路径
oEv.stroke();//调用触笔方法(canvas)
//圆的画法
oEv.beginPath();//画圆
oEv.arc(300,300,200,0,2*Math.PI,false);
oEv.strokeStyle='green';
oEv.closePath();
oEv.stroke();
//正方体的画法
oEv.beginPath();
oEv.fillStyle='pink';
oEv.fillRect(300,300,350,350);
oEv.closePath();
oEv.stroke();