从body开始复制,清除画布之后把鼠标移上还是出现原图,求具体方法<body><canvas id="bo" width="500" height="500">您的浏览器不支持次应用,请更新浏览器</canvas><input type="button" onclick="clea()" value="清空" /><script>var canvas = document.getElementById('bo');var pic=canvas.getContext("2d");pic.lineWidth=5;pic.strokeStyle="red";var con=false;$("#bo").mousedown(function(e){var mouseX = e.pageX - this.offsetLeft;var mouseY = e.pageY - this.offsetTop; con=true;pic.moveTo(mouseX,mouseY);});$("#bo").mouseup(function(e){con=false;})$("#bo").mousemove(function(e){var mouseX = e.pageX - this.offsetLeft;var mouseY = e.pageY - this.offsetTop;if(con)pic.lineTo(mouseX,mouseY);pic.stroke();})function clea(){pic.clearRect(0,0,500,500);}</script>
3 回答
慕仙森
TA贡献1827条经验 获得超7个赞
1 2 3 4 5 6 7 | function clea(){ var canvas = document.getElementById('bo'); var context=canvas.getContext("2d"); context.clearRect(0,0,canvas.width,canvas.height); context.beginPath(); }; /*试试这个效果,希望能帮到你*/ |
- 3 回答
- 0 关注
- 574 浏览
添加回答
举报
0/150
提交
取消