关于自由拖拽完成的剪切区域(UI组件之图片剪切器)
var x, y,areaWidth,areaHeight; var down;//闪光的判断标准,很好 addEvent(canvas,'mousedown',function(e){ // console.log(e.offsetX + ' '+e.offsetY) down = true; x = e.offsetX; y = e.offsetY; clipArea(x, y,1,1); }) addEvent(canvas,'mousemove',function(e){ if(down){ areaWidth = e.offsetX - x; areaHeight = e.offsetY - y; clipArea(x, y,areaWidth,areaHeight); } }) addEvent(canvas,'mouseup',function(e){ addEvent(canvas,'moumove',function(){}); down = false; areaWidth = e.offsetX - x; areaHeight = e.offsetY - y; clipArea(x, y,areaWidth,areaHeight); })