(function(){/**
* 实现画圆和划线:
* 1、添加事件touchstart、touchmove、touchend
* 2、touchstart判断是否点击的位置处于圆内getPosition,处于则初始化
* lastpoint、restPoint
* 3、touchmove做的就是:画圆drawPoint和画线drawLine
*
* 实现自动画圆的效果
* 1、检测手势移动的位置是否处于圆内
* 2、圆内的话则画圆 drawPoint
* 3、已经画过实心圆的圆,无需重复检测
*
* 实现解锁成功:
* 1、检测路径是否是对的
* 2、如果是对的就重置,圆圈变绿
* 3、不对也重置,圆圈变红
* 4、重置*/window.canvasLock= function(obj){this.height =obj.height;this.width =obj.width;this.chooseType =obj.chooseType;
};//js方式动态生成dom
canvasLock.prototype.initDom = function(){var wrap = document.createElement('div');var str = '
绘制解锁图案
';wrap.setAttribute('style','position: absolute;top:0;left:0;right:0;bottom:0;');var canvas = document.createElement('canvas');
canvas.setAttribute('id','canvas');
canvas.style.cssText= 'background-color: #305066;display: inline-block;margin-top: 15px;';
wrap.innerHTML=str;
wrap.appendChild(canvas);var width = this.width || 300;var height = this.height || 300;
document.body.appendChild(wrap);//高清屏锁放
canvas.style.width = width + "px";