本文将为您描述用canvas写一个简易画图工具,具体操作方法:
Documentstyle="border:1px solid #000000;">您的浏览器不支持canvas
var c =document.querySelector('#myCanvas');
// 标识画布并指明上下文
var ctx = c.getContext('2d');
ctx.strokeStyle = '#000';
ctx.lineWidth = 3;
c.onmousedown = function (ev){
ctx.beginPath();
ctx.moveTo(ev.clientX,ev.clientY)
c.onmousemove = function (ev) {
ctx.lineTo(ev.clientX,ev.clientY);
ctx.stroke()
}
c.onmouseup = function () {
c.onmousemove = null;
}
}
用canvas写一个简易画图工具就为您介绍到这里,感谢您关注懒咪学编程c.lanmit.com.
本文地址:https://c.lanmit.com/Webqianduan/htmlyucss/24287.html