// Copyright 2006 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // patched with http://code.google.com/p/explorercanvas/issues/detail?id=79 compressed with AjaxMin document.createElement("canvas").getContext||function(){function ut(){return this.context_||(this.context_=new a(this))}function rt(n,t){var r=d.call(arguments,2);return function(){return n.apply(t,r.concat(d.call(arguments)))}}function it(n){var t=n.srcElement;switch(n.propertyName){case"width":t.style.width=t.attributes.width.nodeValue+"px",t.getContext().clearRect();break;case"height":t.style.height=t.attributes.height.nodeValue+"px",t.getContext().clearRect()}}function nt(n){var t=n.srcElement;t.firstChild&&(t.firstChild.style.width=t.clientWidth+"px",t.firstChild.style.height=t.clientHeight+"px")}function l(){return[[1,0,0],[0,1,0],[0,0,1]]}function e(n,t){for(var e=l(),i,f,r,u=0;u<3;u++)for(i=0;i<3;i++){for(f=0,r=0;r<3;r++)f+=n[u][r]*t[r][i];e[u][i]=f}return e}function p(n,t){t.fillStyle=n.fillStyle,t.lineCap=n.lineCap,t.lineJoin=n.lineJoin,t.lineWidth=n.lineWidth,t.miterLimit=n.miterLimit,t.shadowBlur=n.shadowBlur,t.shadowColor=n.shadowColor,t.shadowOffsetX=n.shadowOffsetX,t.shadowOffsetY=n.shadowOffsetY,t.strokeStyle=n.strokeStyle,t.globalAlpha=n.globalAlpha,t.arcScaleX_=n.arcScaleX_,t.arcScaleY_=n.arcScaleY_,t.lineScale_=n.lineScale_}function g(n){var i,f=1,t;if(n=String(n),n.substring(0,3)=="rgb"){var u=n.indexOf("(",3),e=n.indexOf(")",u+1),r=n.substring(u+1,e).split(",");for(i="#",t=0;t<3;t++)i+=c[Number(r[t])];r.length==4&&n.substr(3,1)=="a"&&(f=r[3])}else i=n;return{color:i,alpha:f}}function ft(n){switch(n){case"butt":return"flat";case"round":return"round";case"square":default:return"square"}}function a(n){this.m_=l(),this.mStack_=[],this.aStack_=[],this.currentPath_=[],this.strokeStyle="#000",this.fillStyle="#000",this.lineWidth=1,this.lineJoin="miter",this.lineCap="butt",this.miterLimit=i*1,this.globalAlpha=1,this.canvas=n;var t=n.ownerDocument.createElement("div");t.style.width=n.clientWidth+"px",t.style.height=n.clientHeight+"px",t.style.overflow="hidden",t.style.position="absolute",n.appendChild(t),this.element_=t,this.arcScaleX_=1,this.arcScaleY_=1,this.lineScale_=1}function b(n,t,i,r){n.currentPath_.push({type:"bezierCurveTo",cp1x:t.x,cp1y:t.y,cp2x:i.x,cp2y:i.y,x:r.x,y:r.y}),n.currentX_=r.x,n.currentY_=r.y}function tt(n){for(var t,i=0;i<3;i++)for(t=0;t<2;t++)if(!isFinite(n[i][t])||isNaN(n[i][t]))return!1;return!0}function s(n,t,i){if(tt(t)&&(n.m_=t,i)){var r=t[0][0]*t[1][1]-t[0][1]*t[1][0];n.lineScale_=ot(et(r))}}function h(n){this.type_=n,this.x0_=0,this.y0_=0,this.r0_=0,this.x1_=0,this.y1_=0,this.r1_=0,this.colors_=[]}function w(){}var r=Math,t=r.round,y=r.sin,v=r.cos,et=r.abs,ot=r.sqrt,i=10,u=i/2,d=Array.prototype.slice,k={init:function(n){if(/MSIE/.test(navigator.userAgent)&&!window.opera){var t=n||document;t.createElement("canvas"),t.readyState!=="complete"?t.attachEvent("onreadystatechange",rt(this.init_,this,t)):this.init_(t)}},init_:function(n){var i,r,t;for(n.namespaces.g_vml_||n.namespaces.add("g_vml_","urn:schemas-microsoft-com:vml","#default#VML"),n.namespaces.g_o_||n.namespaces.add("g_o_","urn:schemas-microsoft-com:office:office","#default#VML"),n.styleSheets.ex_canvas_||(i=n.createStyleSheet(),i.owningElement.id="ex_canvas_",i.cssText="canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}g_vml_\\:*{behavior:url(#default#VML)}g_o_\\:*{behavior:url(#default#VML)}"),r=n.getElementsByTagName("canvas"),t=0;t','",""),this.element_.insertAdjacentHTML("BeforeEnd",v.join(""))},n.stroke=function(n){var f=[],ti=!1,et=g(n?this.fillStyle:this.strokeStyle),ot=et.color,tt=et.alpha*this.globalAlpha,ht=10,st=10,u,lt,a,d,s,c,y;f.push("h.x)&&(h.x=u.x),(o.y==null||u.yh.y)&&(h.y=u.y))}if(f.push(' ">'),n)if(typeof this.fillStyle=="object"){var e=this.fillStyle,l=0,nt={x:0,y:0},w=0,rt=1;if(e.type_=="gradient"){var dt=e.x0_/this.arcScaleX_,gt=e.y0_/this.arcScaleY_,kt=e.x1_/this.arcScaleX_,bt=e.y1_/this.arcScaleY_,v=this.getCoords_(dt,gt),it=this.getCoords_(kt,bt),wt=it.x-v.x,pt=it.y-v.y;l=Math.atan2(wt,pt)*180/Math.PI,l<0&&(l+=360),l<1e-6&&(l=0)}else{var v=this.getCoords_(e.x0_,e.y0_),b=h.x-o.x,k=h.y-o.y;nt={x:(v.x-o.x)/b,y:(v.y-o.y)/k},b/=this.arcScaleX_*i,k/=this.arcScaleY_*i,d=r.max(b,k),w=2*e.r0_/d,rt=2*e.r1_/d-w}s=e.colors_,s.sort(function(n,t){return n.offset-t.offset});var p=s.length,ct=s[0].color,at=s[p-1].color,yt=s[0].alpha*this.globalAlpha,vt=s[p-1].alpha*this.globalAlpha,ut=[];for(c=0;c')}else f.push('');else a=this.lineScale_*this.lineWidth,a<1&&(tt*=a),f.push("');f.push(""),this.element_.insertAdjacentHTML("beforeEnd",f.join(""))},n.fill=function(){this.stroke(!0)},n.closePath=function(){this.currentPath_.push({type:"close"})},n.getCoords_=function(n,t){var r=this.m_;return{x:i*(n*r[0][0]+t*r[1][0]+r[2][0])-u,y:i*(n*r[0][1]+t*r[1][1]+r[2][1])-u}},n.save=function(){var n={};p(this,n),this.aStack_.push(n),this.mStack_.push(this.m_),this.m_=e(l(),this.m_)},n.restore=function(){p(this.aStack_.pop(),this),this.m_=this.mStack_.pop()},n.translate=function(n,t){var i=[[1,0,0],[0,1,0],[n,t,1]];s(this,e(i,this.m_),!1)},n.rotate=function(n){var i=v(n),t=y(n),r=[[i,t,0],[-t,i,0],[0,0,1]];s(this,e(r,this.m_),!1)},n.scale=function(n,t){this.arcScaleX_*=n,this.arcScaleY_*=t;var i=[[n,0,0],[0,t,0],[0,0,1]];s(this,e(i,this.m_),!0)},n.transform=function(n,t,i,r,u,f){var o=[[n,t,0],[i,r,0],[u,f,1]];s(this,e(o,this.m_),!0)},n.setTransform=function(n,t,i,r,u,f){var e=[[n,t,0],[i,r,0],[u,f,1]];s(this,e,!0)},n.clip=function(){},n.arcTo=function(){},n.createPattern=function(){return new w},h.prototype.addColorStop=function(n,t){t=g(t),this.colors_.push({offset:n,color:t.color,alpha:t.alpha})},G_vmlCanvasManager=k,CanvasRenderingContext2D=a,CanvasGradient=h,CanvasPattern=w}();