<!DOCTYPE html><html><head> <meta charset="UTF-8"> <meta name="Keywords" content=""> <meta name="Description" content=""> <title></title></head><style type="text/css"> body{ margin:0px; background:#000; } #canvas{ display:block; background:#fff; width:500px; height:500px; margin:50px auto; }</style><body> <canvas id="canvas">asdf</canvas></body><script> var cxt = canvas.getContext("2d"); cxt.save();//保存路径 cxt.beginPath();//开始路径 cxt.arc(250,250,100,0,Math.PI*2,false); cxt.closePath();//结束路径 cxt.fill();//填充方法 cxt.restore();//释放路径 // https://blog.csdn.net/cat_foursi/article/details/71543775 </script></html>
1 回答
realwds
TA贡献69条经验 获得超24个赞
Script 写错了,先获取id
var canvas=document.getElementById("canvas");
var ctx=canvas.getContext('2d')
添加回答
举报
0/150
提交
取消