为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我的这个米字格里的细线出不来

js代码

var canvasWidth=800;
var canvasHeight=canvasWidth;

var canvas=document.getElementById("canvas");
var context=canvas.getContext("2d");

canvas.width=canvasWidth;
canvas.height=canvasHeight;
context.strokeStyle="rgb(230,11,9)";

context.beginPath();
context.lineTo(3,3);
context.lineTo(canvasWidth-3,3);
context.lineTo(canvasWidth-3,canvasHeight-3);
context.lineTo(3,canvasHeight-3);
context.closePath();

context.lineWidth=6;
context.stroke();

context.beginPath();
context.moveTo(0,0);
context.lineTo(canvasWidth,canvasHeight);

context.moveTo(canvasWidth,0);
context.lineTo(0,canvasHeight);

canvas.moveTo(canvasWidth/2,0);
canvas.lineTo(canvasWidth/2,canvasHeight);

canvas.moveTo(0,canvasHeight/2);
canvas.lineTo(canvasWidth,canvasHeight/2);

context.lineWidth=1;
context.stroke();


正在回答

1 回答

是cointext.moveTo()  你到后面4行写成canvas.moveTo()了  浏览器调试栏里有报错吧

1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

为什么我的这个米字格里的细线出不来

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信