function MiaovDraw(w, h, parent) { var bIsIE=(/ie/i).test(window.navigator.userAgent); this.width= w; this.height= h; var tmp = 0; var browser=navigator.appName; var b_version=navigator.appVersion; var version=b_version.split(";"); var trim_Version = ""; if (version.length>1) { var trim_Version=version[1].replace(/[ ]/g,""); } //alert(browser + " " + trim_Version); bIsIE = browser=="Microsoft Internet Explorer" && (trim_Version=="MSIE7.0" || trim_Version=="MSIE8.0"); if(bIsIE) //if(browser=="Microsoft Internet Explorer" && (trim_Version=="MSIE7.0" || trim_Version=="MSIE8.0")) { //document.namespaces.add("mv","urn:schemas-microsoft-com:vml"); //document.createStyleSheet().addRule(".mv", "behavior:url(#default#VML)"); this.container=document.createElement(''); this.container.style.position='absolute'; this.container.style.width=w+'px'; this.container.style.height=h+'px'; this.container.coordsize=w+','+h; this.container.style.left='0px'; this.container.style.top='0px'; parent.appendChild(this.container); this.reappend=function () { parent.appendChild(this.container); }; } else { var canvas=document.createElement('canvas'); canvas.style.position='absolute'; canvas.width=w; canvas.height=h; canvas.innerHTML='你的浏览器不支持canvas,访问这里了解更多'; canvas.style.left='0px'; canvas.style.top='0px'; parent.appendChild(canvas); this.reappend=function () { parent.appendChild(canvas); }; this.container=canvas.getContext('2d'); this.container.strokeStyle='#00CC00'; //window.setInterval(function(){ // if(tmp==0){ // console.info("111"); // this.container.strokeStyle='#00CC00'; // tmp = 1; // console.info(tmp); // }else{ // this.container.strokeStyle='#e11408'; // console.info("222"); // tmp = 0; // } // //},1000); //this.container.strokeStyle='#e11408'; } var sFn="line|clear"; var arr=sFn.split('|'); for(var i=0;i'); l.from=x1+','+y1; l.to=x2+','+y2; l.strokeColor='#00CC00'; if(this.lineWidth)l.StrokeWeight=this.lineWidth; if(this.strokeColor)l.StrokeColor=this.strokeColor; this.container.appendChild(l); //alert(l.from+'->'+l.to); }; MiaovDraw.prototype.DOM_line=function (x1, y1, x2, y2) { this.container.setLineDash([5,10]); this.container.lineWidth = 2; this.container.moveTo(x1,y1); this.container.lineTo(x2,y2); //document.title=x1+','+y1+'\t'+x2+','+y2; this.container.stroke(); }; MiaovDraw.prototype.xx=function (x1, y1, x2, y2) { this.container.setLineDash([5,5]); this.container.moveTo(x1,y1); this.container.lineTo(x2,y2); //document.title=x1+','+y1+'\t'+x2+','+y2; this.container.stroke(); }; MiaovDraw.prototype.IE_clear=function () { var i=0; for(i=this.container.childNodes.length-1;i>=0;i--) { this.container.removeChild(this.container.childNodes[i]); } }; MiaovDraw.prototype.DOM_clear=function () { this.container.clearRect(0,0,this.width,this.height); };