diff --git a/Gruntfile.js b/Gruntfile.js index f01985c..7c5a9c4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -29,7 +29,7 @@ module.exports = function(grunt) { src: [ "./eve/eve.js", "mina.js", - "elemental.js", + "./third-party/elemental.js", "svg.js", "savage.path.js", "savage.set.js", @@ -40,12 +40,8 @@ module.exports = function(grunt) { } }); - - // These plugins provide necessary tasks. grunt.loadNpmTasks("grunt-contrib-concat"); grunt.loadNpmTasks("grunt-contrib-uglify"); - - // Default task. grunt.registerTask("default", ["concat", "uglify"]); }; \ No newline at end of file diff --git a/package.json b/package.json index 460dfb1..fe2aeb8 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-uglify": "~0.2.0", - "grunt-contrib-concat": "~0.3.0" + "grunt-contrib-concat": "~0.3.0", + "eslint-grunt": "0.0.4" } -} \ No newline at end of file +} diff --git a/savage-min.js b/savage-min.js index 4bb1e33..145a912 100644 --- a/savage-min.js +++ b/savage-min.js @@ -28,6 +28,6 @@ // See the License for the specific language governing permissions and // limitations under the License. // -// build: 2013-08-05 -!function(a){var b,c,d="0.4.2",e="hasOwnProperty",f=/[\.\/]/,g="*",h=function(){},i=function(a,b){return a-b},j={n:{}},k=function(a,d){a=String(a);var e,f=c,g=Array.prototype.slice.call(arguments,2),h=k.listeners(a),j=0,l=[],m={},n=[],o=b;b=a,c=0;for(var p=0,q=h.length;q>p;p++)"zIndex"in h[p]&&(l.push(h[p].zIndex),h[p].zIndex<0&&(m[h[p].zIndex]=h[p]));for(l.sort(i);l[j]<0;)if(e=m[l[j++]],n.push(e.apply(d,g)),c)return c=f,n;for(p=0;q>p;p++)if(e=h[p],"zIndex"in e)if(e.zIndex==l[j]){if(n.push(e.apply(d,g)),c)break;do if(j++,e=m[l[j]],e&&n.push(e.apply(d,g)),c)break;while(e)}else m[e.zIndex]=e;else if(n.push(e.apply(d,g)),c)break;return c=f,b=o,n.length?n:null};k._events=j,k.listeners=function(a){var b,c,d,e,h,i,k,l,m=a.split(f),n=j,o=[n],p=[];for(e=0,h=m.length;h>e;e++){for(l=[],i=0,k=o.length;k>i;i++)for(n=o[i].n,c=[n[m[e]],n[g]],d=2;d--;)b=c[d],b&&(l.push(b),p=p.concat(b.f||[]));o=l}return p},k.on=function(a,b){if(a=String(a),"function"!=typeof b)return function(){};for(var c=a.split(f),d=j,e=0,g=c.length;g>e;e++)d=d.n,d=d.hasOwnProperty(c[e])&&d[c[e]]||(d[c[e]]={n:{}});for(d.f=d.f||[],e=0,g=d.f.length;g>e;e++)if(d.f[e]==b)return h;return d.f.push(b),function(a){+a==+a&&(b.zIndex=+a)}},k.f=function(a){var b=[].slice.call(arguments,1);return function(){k.apply(null,[a,null].concat(b).concat([].slice.call(arguments,0)))}},k.stop=function(){c=1},k.nt=function(a){return a?new RegExp("(?:\\.|\\/|^)"+a+"(?:\\.|\\/|$)").test(b):b},k.nts=function(){return b.split(f)},k.off=k.unbind=function(a,b){if(!a)return k._events=j={n:{}},void 0;var c,d,h,i,l,m,n,o=a.split(f),p=[j];for(i=0,l=o.length;l>i;i++)for(m=0;mi;i++)for(c=p[i];c.n;){if(b){if(c.f){for(m=0,n=c.f.length;n>m;m++)if(c.f[m]==b){c.f.splice(m,1);break}!c.f.length&&delete c.f}for(d in c.n)if(c.n[e](d)&&c.n[d].f){var q=c.n[d].f;for(m=0,n=q.length;n>m;m++)if(q[m]==b){q.splice(m,1);break}!q.length&&delete c.n[d].f}}else{delete c.f;for(d in c.n)c.n[e](d)&&c.n[d].f&&delete c.n[d].f}c=c.n}},k.once=function(a,b){var c=function(){return k.unbind(a,c),b.apply(this,arguments)};return k.on(a,c)},k.version=d,k.toString=function(){return"You are running Eve "+d},"undefined"!=typeof module&&module.exports?module.exports=k:"undefined"!=typeof define?define("eve",[],function(){return k}):a.eve=k}(this),window.mina=function(){var a=[],b=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,16)},c=Array.isArray||function(a){return a instanceof Array||"[object Array]"==Object.prototype.toString.call(a)},d=function(a,b,e,f){if(c(a)){res=[];for(var g=0,h=a.length;h>g;g++)res[g]=d(a[g],b,e[g],f);return res}var i=(e-a)/(f-b);return function(c){return a+i*(c-b)}},e=function(){return+new Date},f=function(){for(var d,e,g=0;gj;j++)d[j]=h.dif[j](i),e=h.A[j]-h.a[j],d[j]=e?h.a[j]+h.easing((d[j]-h.a[j])/e)*e:h.a[j]}else d=h.dif(i),e=h.A-h.a,d=h.a+h.easing((d-h.a)/e)*e;try{h.stopper(i)?--h.iterations?h["+"]+=h.b-h.B:(a.splice(g--,1),h.framer(h.A),h.callback&&h.callback()):h.framer(d)}catch(l){console.error(l)}}a.length&&b(f)},g=function(a){if(this["*"]=Math.abs(a),this.speed=a,0>a){var b=this.a;this.a=this.A,this.A=b,this.dif=d(this.a,this.b,this.A,this.B),this.stopper=j(this.b,this.B)}},h=function(){for(var b=0,c=a.length;c>b;b++)if(a[b]==this)return a.splice(b,1),void 0},i=function(c,e,i,j,l,m,n,o){var p={framer:l,callback:m,dif:d(c,i,e,j),easing:k.linear,"+":0,"*":1,gen:n,speed:1,iterations:1,stopper:o,a:c,b:i,A:e,B:j,setSpeed:g,stop:h};return a.push(p),1==a.length&&b(f),p},j=function(a,b){return function(c){return b>a?c>=b:b>=c}},k=function(a,b,c,d,f){var g=e(),h=g+c;return d(a),i(a,b,g,h,d,f,e,j(g,h))};return k.linear=function(a){return a},k.easeout=function(a){return Math.pow(a,1.7)},k.easein=function(a){return Math.pow(a,.48)},k.easeinout=function(a){var b=.48-a/1.04,c=Math.sqrt(.1734+b*b),d=c-b,e=Math.pow(Math.abs(d),1/3)*(0>d?-1:1),f=-c-b,g=Math.pow(Math.abs(f),1/3)*(0>f?-1:1),h=e+g+.5;return 3*(1-h)*h*h+h*h*h},k.backin=function(a){var b=1.70158;return a*a*((b+1)*a-b)},k.backout=function(a){a-=1;var b=1.70158;return a*a*((b+1)*a+b)+1},k.elastic=function(a){return a==!!a?a:Math.pow(2,-10*a)*Math.sin((a-.075)*2*Math.PI/.3)+1},k.bounce=function(a){var b,c=7.5625,d=2.75;return 1/d>a?b=c*a*a:2/d>a?(a-=1.5/d,b=c*a*a+.75):2.5/d>a?(a-=2.25/d,b=c*a*a+.9375):(a-=2.625/d,b=c*a*a+.984375),b},k}(),function(){function a(a){a=a||Object(a);for(var c,d,e=1,g=a.length+1,h=b(a,0);g>e;e++)c=d,d=h,h=b(a,e),this.raw+=d,f.call(this,d,h,c);return this._beforeEnd=function(){f.call(this,"","",d)},this}function b(a,b){return a&&(a.charAt?a.charAt(b):a[b])}function c(a,b){this.events=this.events||{},this.events[a]=this.events[a]||[],this.events[a].push(b)}function d(a,b,c){"function"==typeof eve&&eve("elemental."+a+"."+b,null,b,c||"",this.raw);for(var d=this.events&&this.events[a],e=d&&d.length;e--;)try{this.events[a][e](b,c||"",this.raw)}catch(f){}this.raw=""}function e(){f.call(this,"eof"),this.event("eof")}function f(a,b,c){"\n"==a&&this.event("newline"),j[this.mode].call(this,a,b,c)}function g(b){var f=function(a){f.parse(a)};return f.mode="text",f.type=String(b||"html").toLowerCase(),f.textchunk="",f.raw="",f.parse=a,f.on=c,f.event=d,f.end=e,f}var h=/[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000]/,i=function(){for(var a in this.attr)this.attr.hasOwnProperty(a)&&this.event("attr",a,{value:this.attr[a],tagname:this.tagname,attr:this.attr})},j={text:function(a){switch(a){case"<":case"eof":this.nodename="",this.attr={},this.mode="tag name start",this.raw=this.raw.slice(0,-1),this.textchunk&&this.event("text",this.textchunk),this.raw+=a,this.textchunk="";break;default:this.textchunk+=a}},special:function(a,b,c){return"!"==c&&"-"==a&&"-"==b?(this.mode="comment start",void 0):"[CDATA"==this.textchunk&&"["==a?(this.mode="cdata",this.textchunk="",void 0):">"==a||"eof"==a?(this.event("special",this.textchunk),this.mode="text",this.textchunk="",void 0):(this.textchunk+=a,void 0)},cdata:function(a,b,c){return"]"==c&&"]"==a&&">"==b?(this.mode="cdata end",this.textchunk=this.textchunk.slice(0,-1),void 0):("eof"==a&&j["cdata end"].call(this),this.textchunk+=a,void 0)},"cdata end":function(){this.event("cdata",this.textchunk),this.textchunk="",this.mode="text"},"comment start":function(a,b){">"==b||"eof"==a?(this.event("comment",""),this.mode="comment instant end"):this.mode="comment"},"comment instant end":function(){this.mode="text"},comment:function(a,b,c){"-"==a&&"-"==c&&">"==b?(this.mode="comment end",this.textchunk=this.textchunk.slice(0,-1)):"eof"==a?this.event("comment",this.textchunk):this.textchunk+=a},"comment end":function(){this.event("comment",this.textchunk),this.textchunk="",this.mode="text"},declaration:function(a,b){return"?"==a&&">"==b?(this.mode="declaration end",void 0):("eof"==a&&this.event("comment",this.textchunk),this.textchunk+=a,void 0)},"declaration end":function(){this.event("comment",this.textchunk),this.textchunk="",this.mode="text"},"tag name start":function(a,b,c){if("eof"==a)return this.event("text","<"),void 0;if(!h.test(a)){if(this.mode="tag name","/"==a)return this.mode="close tag name start",void 0;if("!"==a)return this.mode="special",this.textchunk="",void 0;if("?"==a)return this.mode="declaration",void 0;j[this.mode].call(this,a,b,c)}},"close tag name start":function(a,b,c){h.test(a)||(this.mode="close tag name",this.tagname="",this.nodename="",j[this.mode].call(this,a,b,c))},"close tag name":function(a){if(h.test(a))this.tagname=this.nodename;else switch(a){case">":this.event("/tag",this.tagname||this.nodename),this.mode="text";break;default:!this.tagname&&(this.nodename+=a)}},"tag name":function(a){if(h.test(a))this.tagname=this.nodename,this.nodename="",this.mode="attr start";else switch(a){case">":this.event("tag",this.nodename),this.mode="text";break;default:this.nodename+=a}},"attr start":function(a,b,c){h.test(a)||(this.mode="attr",this.nodename="",j[this.mode].call(this,a,b,c))},attr:function(a){if(h.test(a)||"="==a)this.attr[this.nodename]="",this.mode="attr value start";else switch(a){case">":"/"==this.nodename?(delete this.attr["/"],this.event("tag",this.tagname,this.attr),i.call(this),this.event("/tag",this.tagname,!0)):(this.nodename&&(this.attr[this.nodename]=""),this.event("tag",this.tagname,this.attr),i.call(this)),this.mode="text";break;default:this.nodename+=a}},"attr value start":function(a,b,c){if(!h.test(a)){if(this.mode="attr value",this.quote=!1,"'"==a||'"'==a)return this.quote=a,void 0;j[this.mode].call(this,a,b,c)}},"attr value":function(a,b,c){if(h.test(a)&&!this.quote)this.mode="attr start";else if(">"!=a||this.quote)switch(a){case'"':case"'":this.quote==a&&"\\"!=c&&(this.mode="attr start");break;default:this.attr[this.nodename]+=a}else this.event("tag",this.tagname,this.attr),this.mode="text"}};g.version="0.2.1",("undefined"==typeof exports?this:exports).elemental=g}();var $VG,Savage=$VG=function(){function a(a,b){if(a){if(a.tagName)return new n(a);if(a instanceof n)return a;if(null==b)return new n(t.doc.querySelector(a))}return a=null==a?"100%":a,b=null==b?"100%":b,new r(a,b)}function b(a,c){if(c){if("string"==typeof a&&(a=b(a)),"string"==typeof c)return a.getAttribute(c);for(var d in c)if(c[u](d)){var e=v(c[d]);e?"xlink:"==d.substring(0,6)?a.setAttributeNS(T,d.substring(6),e):a.setAttribute(d,e):a.removeAttribute(d)}}else a=t.doc.createElementNS("http://www.w3.org/2000/svg",a);return a}function c(a,b){return b=v.prototype.toLowerCase.call(b),"finite"==b?!H[u](+a):"array"==b&&(a instanceof Array||Array.isArray&&Array.isArray(a))?!0:"null"==b&&null===a||b==typeof a&&null!==a||"object"==b&&a===Object(a)||F.call(a).slice(8,-1).toLowerCase()==b}function d(a){if("function"==typeof a||Object(a)!==a)return a;var b=new a.constructor;for(var c in a)a[u](c)&&(b[c]=d(a[c]));return b}function e(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return a.push(a.splice(c,1)[0])}function f(a,b,c){function d(){var f=Array.prototype.slice.call(arguments,0),g=f.join("␀"),h=d.cache=d.cache||{},i=d.count=d.count||[];return h[u](g)?(e(i,g),c?c(h[g]):h[g]):(i.length>=1e3&&delete h[i.shift()],i.push(g),h[g]=a.apply(b,f),c?c(h[g]):h[g])}return d}function g(a){return a%360*C/180}function h(a){return 180*a/C%360}function i(){return this.x+E+this.y+E+this.width+" × "+this.height}function j(a,b,c,d,e,f){return null==b&&"[object SVGMatrix]"==F.call(a)?(this.a=a.a,this.b=a.b,this.c=a.c,this.d=a.d,this.e=a.e,this.f=a.f,void 0):(null!=a?(this.a=+a,this.b=+b,this.c=+c,this.d=+d,this.e=+e,this.f=+f):(this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0),void 0)}function k(a){var b=[];return a=a.replace(/(?:^|\s)(\w+)\(([^)]+)\)/g,function(a,c,d){return d=d.split(/\s*,\s*/),"rotate"==c&&1==d.length&&d.push(0,0),"scale"==c&&(2==d.length&&d.push(0,0),1==d.length&&d.push(d[0],0,0)),"skewX"==c?b.push(["m",1,0,y.tan(g(d[0])),1,0,0]):"skewY"==c?b.push(["m",1,y.tan(g(d[0])),0,1,0,0]):b.push([c.charAt(0)].concat(d)),a}),b}function l(a,b){if(null==b){var c=!0;if(b="linearGradient"==a.type||"radialGradient"==a.type?a.node.getAttribute("gradientTransform"):"pattern"==a.type?a.node.getAttribute("patternTransform"):a.node.getAttribute("transform"),!b)return new j;b=k(b)}else b=bb.test(b)?v(b).replace(/\.{3}|\u2026/g,a._.transform||D):k(b);var d=ab(b),e=0,f=0,g=0,h=1,i=1,l=a._,m=new j;if(l.transform=d||[],d){for(var n=0,o=d.length;o>n;n++){var p,q,r,s,t,u=d[n],w=u.length,x=v(u[0]).toLowerCase(),y=u[0]!=x,z=y?m.invert():0;"t"==x&&3==w?y?(p=z.x(0,0),q=z.y(0,0),r=z.x(u[1],u[2]),s=z.y(u[1],u[2]),m.translate(r-p,s-q)):m.translate(u[1],u[2]):"r"==x?2==w?(t=t||a.getBBox(1),m.rotate(u[1],t.x+t.width/2,t.y+t.height/2),e+=u[1]):4==w&&(y?(r=z.x(u[2],u[3]),s=z.y(u[2],u[3]),m.rotate(u[1],r,s)):m.rotate(u[1],u[2],u[3]),e+=u[1]):"s"==x?2==w||3==w?(t=t||a.getBBox(1),m.scale(u[1],u[w-1],t.x+t.width/2,t.y+t.height/2),h*=u[1],i*=u[w-1]):5==w&&(y?(r=z.x(u[3],u[4]),s=z.y(u[3],u[4]),m.scale(u[1],u[2],r,s)):m.scale(u[1],u[2],u[3],u[4]),h*=u[1],i*=u[2]):"m"==x&&7==w&&m.add(u[1],u[2],u[3],u[4],u[5],u[6])}if(c)return m;l.dirtyT=1,a.matrix=m}a.matrix=m,l.sx=h,l.sy=i,l.deg=e,l.dx=f=m.e,l.dy=g=m.f,1==h&&1==i&&!e&&l.bbox?(l.bbox.x+=+f,l.bbox.y+=+g):l.dirtyT=1}function m(a,c,d){function e(a){return null==a?D:a==+a?a:(b(j,{width:a}),j.getBBox().width)}function f(a){return null==a?D:a==+a?a:(b(j,{height:a}),j.getBBox().height)}function g(b,e){null==c?i[b]=e(a.attr(b)):b==c&&(i=e(null==d?a.attr(b):d))}var h=a.paper.defs,i={},j=a.paper.measurer;switch(j||(a.paper.measurer=j=b("rect"),b(j,{width:10,height:10}),h.appendChild(j)),a.type){case"rect":g("rx",e),g("ry",f);case"image":g("width",e),g("height",f);case"text":g("x",e),g("y",f);break;case"circle":g("cx",e),g("cy",f),g("r",e);break;case"ellipse":g("cx",e),g("cy",f),g("rx",e),g("ry",f);break;case"line":g("x1",e),g("x2",e),g("y1",f),g("y2",f);break;case"marker":g("refX",e),g("markerWidth",e),g("refY",f),g("markerHeight",f);break;case"radialGradient":g("fx",e),g("fy",f);break;case"tspan":g("dx",e),g("dy",f);break;default:i=null}return i}function n(a){if(a.savage in U)return U[a.savage];var b,c=this.id=S();try{b=a.ownerSVGElement}catch(d){}this.node=a,b&&(this.paper=new r(b)),this.type=a.tagName,this._={transform:[],sx:1,sy:1,deg:0,dx:0,dy:0,dirty:1},a.savage=c,U[c]=this}function o(a){for(var b,c=0,d=a.length;d>c;c++)if(b=b||a[c])return b}function p(a){this.node=a}function q(a,c){var d=b(a);c.appendChild(d);var e=new n(d);return e.type=a,e}function r(a,c){var d,e,f,g=r.prototype;if(a&&"svg"==a.tagName){if(a.savage in U)return U[a.savage];d=new n(a),e=a.getElementsByTagName("desc")[0],f=a.getElementsByTagName("defs")[0]}else d=q("svg",t.doc.body),b(d.node,{height:c,version:1.1,width:a,xmlns:"http://www.w3.org/2000/svg"});e||(e=b("desc"),e.appendChild(t.doc.createTextNode("Created with Savage")),d.node.appendChild(e)),f||(f=b("defs"),d.node.appendChild(f));for(var h in g)g[u](h)&&(d[h]=g[h]);return d.paper=d,d.defs=f,d}function s(a){return a instanceof n||a instanceof p?a:new n(a)}a.version="0.0.1",a.toString=function(){return"Savage v"+this.version},a._={};var t={win:window,doc:window.document},u="hasOwnProperty",v=String,w=parseFloat,x=parseInt,y=Math,z=y.max,A=y.min,B=y.abs,C=(y.pow,y.PI),D=(y.round,""),E=" ",F=Object.prototype.toString,G=/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i,H={NaN:1,Infinity:1,"-Infinity":1},I=/^url\(#?([^)]+)\)$/,J=" \n \f\r   ᠎              \u2028\u2029",K=new RegExp("[,"+J+"]+"),L=(new RegExp("["+J+"]","g"),new RegExp("["+J+"]*,["+J+"]*")),M={hs:1,rg:1},N=new RegExp("([a-z])["+J+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+J+"]*,?["+J+"]*)+)","ig"),O=new RegExp("([rstm])["+J+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+J+"]*,?["+J+"]*)+)","ig"),P=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+J+"]*,?["+J+"]*","ig"),Q=0,R="S"+(+new Date).toString(36),S=function(){return R+(Q++).toString(36)},T="http://www.w3.org/1999/xlink",U={};a._.$=b;var V=function(){function a(){this.parentNode.removeChild(this)}return function(b,c){var d=t.doc.createElement("img"),e=t.doc.body;d.style.cssText="position:absolute;left:-9999em;top:-9999em",d.onload=function(){c.call(d),d.onload=d.onerror=null,e.removeChild(d)},d.onerror=a,e.appendChild(d),d.src=b}}();a._.clone=d,a._.cacher=f,a.rad=g,a.deg=h,a.is=c,a.snapTo=function(a,b,d){if(d=c(d,"finite")?d:10,c(a,"array")){for(var e=a.length;e--;)if(B(a[e]-b)<=d)return a[e]}else{a=+a;var f=b%a;if(d>f)return b-f;if(f>a-d)return b-f+a}return b},function(a){function b(a){return a[0]*a[0]+a[1]*a[1]}function c(a){var c=y.sqrt(b(a));a[0]&&(a[0]/=c),a[1]&&(a[1]/=c)}a.add=function(a,b,c,d,e,f){var g,h,i,k,l=[[],[],[]],m=[[this.a,this.c,this.e],[this.b,this.d,this.f],[0,0,1]],n=[[a,c,e],[b,d,f],[0,0,1]];for(a&&a instanceof j&&(n=[[a.a,a.c,a.e],[a.b,a.d,a.f],[0,0,1]]),g=0;3>g;g++)for(h=0;3>h;h++){for(k=0,i=0;3>i;i++)k+=m[g][i]*n[i][h];l[g][h]=k}return this.a=l[0][0],this.b=l[1][0],this.c=l[0][1],this.d=l[1][1],this.e=l[0][2],this.f=l[1][2],this},a.invert=function(){var a=this,b=a.a*a.d-a.b*a.c;return new j(a.d/b,-a.b/b,-a.c/b,a.a/b,(a.c*a.f-a.d*a.e)/b,(a.b*a.e-a.a*a.f)/b)},a.clone=function(){return new j(this.a,this.b,this.c,this.d,this.e,this.f)},a.translate=function(a,b){return this.add(1,0,0,1,a,b)},a.scale=function(a,b,c,d){return null==b&&(b=a),(c||d)&&this.add(1,0,0,1,c,d),this.add(a,0,0,b,0,0),(c||d)&&this.add(1,0,0,1,-c,-d),this},a.rotate=function(a,b,c){a=g(a),b=b||0,c=c||0;var d=+y.cos(a).toFixed(9),e=+y.sin(a).toFixed(9);return this.add(d,e,-e,d,b,c),this.add(1,0,0,1,-b,-c)},a.x=function(a,b){return a*this.a+b*this.c+this.e},a.y=function(a,b){return a*this.b+b*this.d+this.f},a.get=function(a){return+this[v.fromCharCode(97+a)].toFixed(4)},a.toString=function(){return"matrix("+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)].join()+")"},a.offset=function(){return[this.e.toFixed(4),this.f.toFixed(4)]},a.split=function(){var a={};a.dx=this.e,a.dy=this.f;var d=[[this.a,this.c],[this.b,this.d]];a.scalex=y.sqrt(b(d[0])),c(d[0]),a.shear=d[0][0]*d[1][0]+d[0][1]*d[1][1],d[1]=[d[1][0]-d[0][0]*a.shear,d[1][1]-d[0][1]*a.shear],a.scaley=y.sqrt(b(d[1])),c(d[1]),a.shear/=a.scaley;var e=-d[0][1],f=d[1][1];return 0>f?(a.rotate=h(y.acos(f)),0>e&&(a.rotate=360-a.rotate)):a.rotate=h(y.asin(e)),a.isSimple=!(+a.shear.toFixed(9)||a.scalex.toFixed(9)!=a.scaley.toFixed(9)&&a.rotate),a.isSuperSimple=!+a.shear.toFixed(9)&&a.scalex.toFixed(9)==a.scaley.toFixed(9)&&!a.rotate,a.noRotation=!+a.shear.toFixed(9)&&!a.rotate,a},a.toTransformString=function(a){var b=a||this.split();return b.isSimple?(b.scalex=+b.scalex.toFixed(4),b.scaley=+b.scaley.toFixed(4),b.rotate=+b.rotate.toFixed(4),(b.dx||b.dy?"t"+[+b.dx.toFixed(4),+b.dy.toFixed(4)]:D)+(1!=b.scalex||1!=b.scaley?"s"+[b.scalex,b.scaley,0,0]:D)+(b.rotate?"r"+[+b.rotate.toFixed(4),0,0]:D)):"m"+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)]}}(j.prototype),a.Matrix=j,a.getRGB=f(function(b){if(!b||(b=v(b)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:Z};if("none"==b)return{r:-1,g:-1,b:-1,hex:"none",toString:Z};!(M[u](b.toLowerCase().substring(0,2))||"#"==b.charAt())&&(b=W(b));var d,e,f,g,h,i,j=b.match(G);return j?(j[2]&&(f=x(j[2].substring(5),16),e=x(j[2].substring(3,5),16),d=x(j[2].substring(1,3),16)),j[3]&&(f=x((h=j[3].charAt(3))+h,16),e=x((h=j[3].charAt(2))+h,16),d=x((h=j[3].charAt(1))+h,16)),j[4]&&(i=j[4].split(L),d=w(i[0]),"%"==i[0].slice(-1)&&(d*=2.55),e=w(i[1]),"%"==i[1].slice(-1)&&(e*=2.55),f=w(i[2]),"%"==i[2].slice(-1)&&(f*=2.55),"rgba"==j[1].toLowerCase().slice(0,4)&&(g=w(i[3])),i[3]&&"%"==i[3].slice(-1)&&(g/=100)),j[5]?(i=j[5].split(L),d=w(i[0]),"%"==i[0].slice(-1)&&(d*=2.55),e=w(i[1]),"%"==i[1].slice(-1)&&(e*=2.55),f=w(i[2]),"%"==i[2].slice(-1)&&(f*=2.55),("deg"==i[0].slice(-3)||"°"==i[0].slice(-1))&&(d/=360),"hsba"==j[1].toLowerCase().slice(0,4)&&(g=w(i[3])),i[3]&&"%"==i[3].slice(-1)&&(g/=100),a.hsb2rgb(d,e,f,g)):j[6]?(i=j[6].split(L),d=w(i[0]),"%"==i[0].slice(-1)&&(d*=2.55),e=w(i[1]),"%"==i[1].slice(-1)&&(e*=2.55),f=w(i[2]),"%"==i[2].slice(-1)&&(f*=2.55),("deg"==i[0].slice(-3)||"°"==i[0].slice(-1))&&(d/=360),"hsla"==j[1].toLowerCase().slice(0,4)&&(g=w(i[3])),i[3]&&"%"==i[3].slice(-1)&&(g/=100),a.hsl2rgb(d,e,f,g)):(j={r:d,g:e,b:f,toString:Z},j.hex="#"+(16777216|f|e<<8|d<<16).toString(16).slice(1),c(g,"finite")&&(j.opacity=g),j)):{r:-1,g:-1,b:-1,hex:"none",error:1,toString:Z}},a),a.hsb=f(function(b,c,d){return a.hsb2rgb(b,c,d).hex}),a.hsl=f(function(b,c,d){return a.hsl2rgb(b,c,d).hex}),a.rgb=f(function(a,b,d,e){if(c(e,"finite")){var f=y.round;return"rgba("+[f(a),f(b),f(d),+e.toFixed(2)]+")"}return"#"+(16777216|d|b<<8|a<<16).toString(16).slice(1)});var W=function(a){var b=t.doc.getElementsByTagName("head")[0];return W=f(function(a){b.style.color="inherit",b.style.color=a;var c=t.doc.defaultView.getComputedStyle(b,D).getPropertyValue("color");return"inherit"==c?null:c}),W(a)},X=function(){return"hsb("+[this.h,this.s,this.b]+")"},Y=function(){return"hsl("+[this.h,this.s,this.l]+")"},Z=function(){return 1==this.opacity||null==this.opacity?this.hex:"rgba("+[this.r,this.g,this.b,this.opacity]+")"},$=function(b,d,e){if(null==d&&c(b,"object")&&"r"in b&&"g"in b&&"b"in b&&(e=b.b,d=b.g,b=b.r),null==d&&c(b,string)){var f=a.getRGB(b);b=f.r,d=f.g,e=f.b}return(b>1||d>1||e>1)&&(b/=255,d/=255,e/=255),[b,d,e]},_=function(b,d,e,f){b=y.round(255*b),d=y.round(255*d),e=y.round(255*e);var g={r:b,g:d,b:e,hex:a.rgb(b,d,e),toString:Z};return c(f,"finite")&&(g.opacity=f),g};a.color=function(b){var d;return c(b,"object")&&"h"in b&&"s"in b&&"b"in b?(d=a.hsb2rgb(b),b.r=d.r,b.g=d.g,b.b=d.b,b.hex=d.hex):c(b,"object")&&"h"in b&&"s"in b&&"l"in b?(d=a.hsl2rgb(b),b.r=d.r,b.g=d.g,b.b=d.b,b.hex=d.hex):(c(b,"string")&&(b=a.getRGB(b)),c(b,"object")&&"r"in b&&"g"in b&&"b"in b?(d=a.rgb2hsl(b),b.h=d.h,b.s=d.s,b.l=d.l,d=a.rgb2hsb(b),b.v=d.b):(b={hex:"none"},b.r=b.g=b.b=b.h=b.s=b.v=b.l=-1)),b.toString=Z,b},a.hsb2rgb=function(a,b,d,e){c(a,"object")&&"h"in a&&"s"in a&&"b"in a&&(d=a.b,b=a.s,a=a.h,e=a.o),a*=360;var f,g,h,i,j;return a=a%360/60,j=d*b,i=j*(1-B(a%2-1)),f=g=h=d-j,a=~~a,f+=[j,i,0,0,i,j][a],g+=[i,j,j,i,0,0][a],h+=[0,0,i,j,j,i][a],_(f,g,h,e)},a.hsl2rgb=function(a,b,d,e){c(a,"object")&&"h"in a&&"s"in a&&"l"in a&&(d=a.l,b=a.s,a=a.h),(a>1||b>1||d>1)&&(a/=360,b/=100,d/=100),a*=360;var f,g,h,i,j;return a=a%360/60,j=2*b*(.5>d?d:1-d),i=j*(1-B(a%2-1)),f=g=h=d-j/2,a=~~a,f+=[j,i,0,0,i,j][a],g+=[i,j,j,i,0,0][a],h+=[0,0,i,j,j,i][a],_(f,g,h,e)},a.rgb2hsb=function(a,b,c){c=$(a,b,c),a=c[0],b=c[1],c=c[2];var d,e,f,g;return f=z(a,b,c),g=f-A(a,b,c),d=0==g?null:f==a?(b-c)/g:f==b?(c-a)/g+2:(a-b)/g+4,d=60*((d+360)%6)/360,e=0==g?0:g/f,{h:d,s:e,b:f,toString:X}},a.rgb2hsl=function(a,b,c){c=$(a,b,c),a=c[0],b=c[1],c=c[2];var d,e,f,g,h,i;return g=z(a,b,c),h=A(a,b,c),i=g-h,d=0==i?null:g==a?(b-c)/i:g==b?(c-a)/i+2:(a-b)/i+4,d=60*((d+360)%6)/360,f=(g+h)/2,e=0==i?0:.5>f?i/(2*f):i/(2-2*f),{h:d,s:e,l:f,toString:Y}},a.parsePathString=function(b){if(!b)return null;var d=a.path(b);if(d.arr)return a.path.clone(d.arr);var e={a:7,c:6,o:2,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,u:3,z:0},f=[];return c(b,"array")&&c(b[0],"array")&&(f=a.path.clone(b)),f.length||v(b).replace(N,function(a,b,c){var d=[],g=b.toLowerCase();if(c.replace(P,function(a,b){b&&d.push(+b)}),"m"==g&&d.length>2&&(f.push([b].concat(d.splice(0,2))),g="l",b="m"==b?"l":"L"),"o"==g&&1==d.length&&f.push([b,d[0]]),"r"==g)f.push([b].concat(d));else for(;d.length>=e[g]&&(f.push([b].concat(d.splice(0,e[g]))),e[g]););}),f.toString=a.path.toString,d.arr=a.path.clone(f),f};var ab=a.parseTransformString=function(b){if(!b)return null;var d=[];return c(b,"array")&&c(b[0],"array")&&(d=a.path.clone(b)),d.length||v(b).replace(O,function(a,b,c){var e=[];b.toLowerCase(),c.replace(P,function(a,b){b&&e.push(+b)}),d.push([b].concat(e))}),d.toString=a.path.toString,d},bb=new RegExp("^[a-z]["+J+"]*-?\\.?\\d");a.select=function(a){return new n(t.doc.querySelector(a))},a.selectAll=function(b){for(var c=t.doc.querySelectorAll(b),d=(a.set||Array)(),e=0;ed;d++){var f=b[d];f.node&&f.node.nodeType&&c.appendChild(f.node),f.nodeType&&c.appendChild(f),"string"==typeof f&&c.appendChild(a.parse(f))}return new p(c)},function(d){function e(a){c(a,"array")||(a=Array.prototype.slice.call(arguments,0));for(var b=0,d=0,e=this.node;this[b];)delete this[b++];for(b=0;b1&&(a=Array.prototype.slice.call(arguments,0));var b=q("polyline",this.node);return c(a,"object")&&!c(a,"array")?b.attr(a):null!=a&&b.attr({points:a}),b},d.polygon=function(a){arguments.length>1&&(a=Array.prototype.slice.call(arguments,0));var b=q("polygon",this.node);return c(a,"object")&&!c(a,"array")?b.attr(a):null!=a&&b.attr({points:a}),b},function(){function c(){return this.selectAll("stop")}function e(a,c){var d=b("stop");return b(d,{"stop-color":a,offset:+c+"%"}),this.node.appendChild(d),this}function f(){if("linearGradient"==this.type){var c=b(this.node,"x1")||0,d=b(this.node,"x2")||1,e=b(this.node,"y1")||0,f=b(this.node,"y2")||0;return a._.box(c,e,y.abs(d-c),y.abs(f-e))}var g=this.node.cx||.5,h=this.node.cy||.5,i=this.node.r||0;return a._.box(g-i,h-i,2*i,2*i)}d.gradient=function(a){function c(a,b){for(var c=(b-h)/(a-i),d=i;a>d;d++)f[d].offset=+(+h+c*(d-i)).toFixed(2);i=a,h=b}var d,e=o(eve("savage.util.grad.parse",null,a));d="l"==e.type.toLowerCase()?this.gradientLinear.apply(this,e.params):this.gradientRadial.apply(this,e.params),e.type!=e.type.toLowerCase()&&b(d.node,{gradientUnits:"userSpaceOnUse"});var f=e.stops,g=f.length,h=0,i=0;g--;for(var j=0;g>j;j++)"offset"in f[j]&&c(j,f[j].offset);for(f[g].offset=f[g].offset||100,c(g,f[g].offset),j=0;g>=j;j++){var k=f[j];d.addStop(k.color,k.offset)}return d},d.gradientLinear=function(a,d,g,h){var i=q("linearGradient",this.node);return i.stops=c,i.addStop=e,i.getBBox=f,null!=a&&b(i.node,{x1:a,y1:d,x2:g,y2:h}),i},d.gradientRadial=function(a,d,g,h,i){var j=q("radialGradient",this.node);return j.stops=c,j.addStop=e,j.getBBox=f,null!=a&&b(j.node,{cx:a,cy:d,r:g}),null!=h&&null!=i&&b(j.node,{fx:h,fy:i}),j}}()}(r.prototype),eve.on("savage.util.attr.mask",function(a){if(a instanceof n||a instanceof p){if(eve.stop(),a instanceof p&&1==a.node.childNodes.length&&(a=a.node.firstChild,this.paper.defs.appendChild(a),a=s(a)),"mask"==a.type)var c=a;else c=q("mask",this.paper.defs),c.node.appendChild(a.node),!c.node.id&&b(c.node,{id:c.id});b(this.node,{mask:"url(#"+c.id+")"})}}),function(a){eve.on("savage.util.attr.clip",a),eve.on("savage.util.attr.clip-path",a),eve.on("savage.util.attr.clipPath",a)}(function(a){if(a instanceof n||a instanceof p){if(eve.stop(),"clipPath"==a.type)var c=a;else c=q("clipPath",this.paper.defs),c.node.appendChild(a.node),!c.node.id&&b(c.node,{id:c.id});b(this.node,{"clip-path":"url(#"+c.id+")"})}}),eve.on("savage.util.attr.fill",function(c){if(eve.stop(),c instanceof p&&1==c.node.childNodes.length&&("radialGradient"==c.node.firstChild.tagName||"linearGradient"==c.node.firstChild.tagName||"pattern"==c.node.firstChild.tagName)&&(c=c.node.firstChild,this.paper.defs.appendChild(c),c=s(c)),c instanceof n&&("radialGradient"==c.type||"linearGradient"==c.type||"pattern"==c.type)){c.node.id||b(c.node,{id:c.id}); +// build: 2013-08-09 +!function(a){var b,c,d="0.4.2",e="hasOwnProperty",f=/[\.\/]/,g="*",h=function(){},i=function(a,b){return a-b},j={n:{}},k=function(a,d){a=String(a);var e,f=c,g=Array.prototype.slice.call(arguments,2),h=k.listeners(a),j=0,l=[],m={},n=[],o=b;b=a,c=0;for(var p=0,q=h.length;q>p;p++)"zIndex"in h[p]&&(l.push(h[p].zIndex),h[p].zIndex<0&&(m[h[p].zIndex]=h[p]));for(l.sort(i);l[j]<0;)if(e=m[l[j++]],n.push(e.apply(d,g)),c)return c=f,n;for(p=0;q>p;p++)if(e=h[p],"zIndex"in e)if(e.zIndex==l[j]){if(n.push(e.apply(d,g)),c)break;do if(j++,e=m[l[j]],e&&n.push(e.apply(d,g)),c)break;while(e)}else m[e.zIndex]=e;else if(n.push(e.apply(d,g)),c)break;return c=f,b=o,n.length?n:null};k._events=j,k.listeners=function(a){var b,c,d,e,h,i,k,l,m=a.split(f),n=j,o=[n],p=[];for(e=0,h=m.length;h>e;e++){for(l=[],i=0,k=o.length;k>i;i++)for(n=o[i].n,c=[n[m[e]],n[g]],d=2;d--;)b=c[d],b&&(l.push(b),p=p.concat(b.f||[]));o=l}return p},k.on=function(a,b){if(a=String(a),"function"!=typeof b)return function(){};for(var c=a.split(f),d=j,e=0,g=c.length;g>e;e++)d=d.n,d=d.hasOwnProperty(c[e])&&d[c[e]]||(d[c[e]]={n:{}});for(d.f=d.f||[],e=0,g=d.f.length;g>e;e++)if(d.f[e]==b)return h;return d.f.push(b),function(a){+a==+a&&(b.zIndex=+a)}},k.f=function(a){var b=[].slice.call(arguments,1);return function(){k.apply(null,[a,null].concat(b).concat([].slice.call(arguments,0)))}},k.stop=function(){c=1},k.nt=function(a){return a?new RegExp("(?:\\.|\\/|^)"+a+"(?:\\.|\\/|$)").test(b):b},k.nts=function(){return b.split(f)},k.off=k.unbind=function(a,b){if(!a)return k._events=j={n:{}},void 0;var c,d,h,i,l,m,n,o=a.split(f),p=[j];for(i=0,l=o.length;l>i;i++)for(m=0;mi;i++)for(c=p[i];c.n;){if(b){if(c.f){for(m=0,n=c.f.length;n>m;m++)if(c.f[m]==b){c.f.splice(m,1);break}!c.f.length&&delete c.f}for(d in c.n)if(c.n[e](d)&&c.n[d].f){var q=c.n[d].f;for(m=0,n=q.length;n>m;m++)if(q[m]==b){q.splice(m,1);break}!q.length&&delete c.n[d].f}}else{delete c.f;for(d in c.n)c.n[e](d)&&c.n[d].f&&delete c.n[d].f}c=c.n}},k.once=function(a,b){var c=function(){return k.unbind(a,c),b.apply(this,arguments)};return k.on(a,c)},k.version=d,k.toString=function(){return"You are running Eve "+d},"undefined"!=typeof module&&module.exports?module.exports=k:"undefined"!=typeof define?define("eve",[],function(){return k}):a.eve=k}(this),window.mina=function(){var a=[],b=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,16)},c=Array.isArray||function(a){return a instanceof Array||"[object Array]"==Object.prototype.toString.call(a)},d=function(a,b,e,f){if(c(a)){res=[];for(var g=0,h=a.length;h>g;g++)res[g]=d(a[g],b,e[g],f);return res}var i=(e-a)/(f-b);return function(c){return a+i*(c-b)}},e=function(){return+new Date},f=function(){for(var d,e,g=0;gj;j++)d[j]=h.dif[j](i),e=h.A[j]-h.a[j],d[j]=e?h.a[j]+h.easing((d[j]-h.a[j])/e)*e:h.a[j]}else d=h.dif(i),e=h.A-h.a,d=h.a+h.easing((d-h.a)/e)*e;try{h.stopper(i)?--h.iterations?h["+"]+=h.b-h.B:(a.splice(g--,1),h.framer(h.A),h.callback&&h.callback()):h.framer(d)}catch(l){console.error(l)}}a.length&&b(f)},g=function(a){if(this["*"]=Math.abs(a),this.speed=a,0>a){var b=this.a;this.a=this.A,this.A=b,this.dif=d(this.a,this.b,this.A,this.B),this.stopper=j(this.b,this.B)}},h=function(){for(var b=0,c=a.length;c>b;b++)if(a[b]==this)return a.splice(b,1),void 0},i=function(c,e,i,j,l,m,n,o){var p={framer:l,callback:m,dif:d(c,i,e,j),easing:k.linear,"+":0,"*":1,gen:n,speed:1,iterations:1,stopper:o,a:c,b:i,A:e,B:j,setSpeed:g,stop:h};return a.push(p),1==a.length&&b(f),p},j=function(a,b){return function(c){return b>a?c>=b:b>=c}},k=function(a,b,c,d,f){var g=e(),h=g+c;return d(a),i(a,b,g,h,d,f,e,j(g,h))};return k.linear=function(a){return a},k.easeout=function(a){return Math.pow(a,1.7)},k.easein=function(a){return Math.pow(a,.48)},k.easeinout=function(a){var b=.48-a/1.04,c=Math.sqrt(.1734+b*b),d=c-b,e=Math.pow(Math.abs(d),1/3)*(0>d?-1:1),f=-c-b,g=Math.pow(Math.abs(f),1/3)*(0>f?-1:1),h=e+g+.5;return 3*(1-h)*h*h+h*h*h},k.backin=function(a){var b=1.70158;return a*a*((b+1)*a-b)},k.backout=function(a){a-=1;var b=1.70158;return a*a*((b+1)*a+b)+1},k.elastic=function(a){return a==!!a?a:Math.pow(2,-10*a)*Math.sin((a-.075)*2*Math.PI/.3)+1},k.bounce=function(a){var b,c=7.5625,d=2.75;return 1/d>a?b=c*a*a:2/d>a?(a-=1.5/d,b=c*a*a+.75):2.5/d>a?(a-=2.25/d,b=c*a*a+.9375):(a-=2.625/d,b=c*a*a+.984375),b},k}(),function(){function a(a){a=a||Object(a);for(var c,d,e=1,g=a.length+1,h=b(a,0);g>e;e++)c=d,d=h,h=b(a,e),this.raw+=d,f.call(this,d,h,c);return this._beforeEnd=function(){f.call(this,"","",d)},this}function b(a,b){return a&&(a.charAt?a.charAt(b):a[b])}function c(a,b){this.events=this.events||{},this.events[a]=this.events[a]||[],this.events[a].push(b)}function d(a,b,c){"function"==typeof eve&&eve("elemental."+a+"."+b,null,b,c||"",this.raw);for(var d=this.events&&this.events[a],e=d&&d.length;e--;)try{this.events[a][e](b,c||"",this.raw)}catch(f){}this.raw=""}function e(){f.call(this,"eof"),this.event("eof")}function f(a,b,c){"\n"==a&&this.event("newline"),j[this.mode].call(this,a,b,c)}function g(b){var f=function(a){f.parse(a)};return f.mode="text",f.type=String(b||"html").toLowerCase(),f.textchunk="",f.raw="",f.parse=a,f.on=c,f.event=d,f.end=e,f}var h=/[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000]/,i=function(){for(var a in this.attr)this.attr.hasOwnProperty(a)&&this.event("attr",a,{value:this.attr[a],tagname:this.tagname,attr:this.attr})},j={text:function(a){switch(a){case"<":case"eof":this.nodename="",this.attr={},this.mode="tag name start",this.raw=this.raw.slice(0,-1),this.textchunk&&this.event("text",this.textchunk),this.raw+=a,this.textchunk="";break;default:this.textchunk+=a}},special:function(a,b,c){return"!"==c&&"-"==a&&"-"==b?(this.mode="comment start",void 0):"[CDATA"==this.textchunk&&"["==a?(this.mode="cdata",this.textchunk="",void 0):">"==a||"eof"==a?(this.event("special",this.textchunk),this.mode="text",this.textchunk="",void 0):(this.textchunk+=a,void 0)},cdata:function(a,b,c){return"]"==c&&"]"==a&&">"==b?(this.mode="cdata end",this.textchunk=this.textchunk.slice(0,-1),void 0):("eof"==a&&j["cdata end"].call(this),this.textchunk+=a,void 0)},"cdata end":function(){this.event("cdata",this.textchunk),this.textchunk="",this.mode="text"},"comment start":function(a,b){">"==b||"eof"==a?(this.event("comment",""),this.mode="comment instant end"):this.mode="comment"},"comment instant end":function(){this.mode="text"},comment:function(a,b,c){"-"==a&&"-"==c&&">"==b?(this.mode="comment end",this.textchunk=this.textchunk.slice(0,-1)):"eof"==a?this.event("comment",this.textchunk):this.textchunk+=a},"comment end":function(){this.event("comment",this.textchunk),this.textchunk="",this.mode="text"},declaration:function(a,b){return"?"==a&&">"==b?(this.mode="declaration end",void 0):("eof"==a&&this.event("comment",this.textchunk),this.textchunk+=a,void 0)},"declaration end":function(){this.event("comment",this.textchunk),this.textchunk="",this.mode="text"},"tag name start":function(a,b,c){if("eof"==a)return this.event("text","<"),void 0;if(!h.test(a)){if(this.mode="tag name","/"==a)return this.mode="close tag name start",void 0;if("!"==a)return this.mode="special",this.textchunk="",void 0;if("?"==a)return this.mode="declaration",void 0;j[this.mode].call(this,a,b,c)}},"close tag name start":function(a,b,c){h.test(a)||(this.mode="close tag name",this.tagname="",this.nodename="",j[this.mode].call(this,a,b,c))},"close tag name":function(a){if(h.test(a))this.tagname=this.nodename;else switch(a){case">":this.event("/tag",this.tagname||this.nodename),this.mode="text";break;default:!this.tagname&&(this.nodename+=a)}},"tag name":function(a){if(h.test(a))this.tagname=this.nodename,this.nodename="",this.mode="attr start";else switch(a){case">":this.event("tag",this.nodename),this.mode="text";break;default:this.nodename+=a}},"attr start":function(a,b,c){h.test(a)||(this.mode="attr",this.nodename="",j[this.mode].call(this,a,b,c))},attr:function(a){if(h.test(a)||"="==a)this.attr[this.nodename]="",this.mode="attr value start";else switch(a){case">":"/"==this.nodename?(delete this.attr["/"],this.event("tag",this.tagname,this.attr),i.call(this),this.event("/tag",this.tagname,!0)):(this.nodename&&(this.attr[this.nodename]=""),this.event("tag",this.tagname,this.attr),i.call(this)),this.mode="text";break;default:this.nodename+=a}},"attr value start":function(a,b,c){if(!h.test(a)){if(this.mode="attr value",this.quote=!1,"'"==a||'"'==a)return this.quote=a,void 0;j[this.mode].call(this,a,b,c)}},"attr value":function(a,b,c){if(h.test(a)&&!this.quote)this.mode="attr start";else if(">"!=a||this.quote)switch(a){case'"':case"'":this.quote==a&&"\\"!=c&&(this.mode="attr start");break;default:this.attr[this.nodename]+=a}else this.event("tag",this.tagname,this.attr),this.mode="text"}};g.version="0.2.1",("undefined"==typeof exports?this:exports).elemental=g}();var $VG,Savage=$VG=function(){function a(a,b){if(a){if(a.tagName)return s(a);if(a instanceof n)return a;if(null==b)return a=t.doc.querySelector(a),s(a)}return a=null==a?"100%":a,b=null==b?"100%":b,new r(a,b)}function b(a,c){if(c){if("string"==typeof a&&(a=b(a)),"string"==typeof c)return a.getAttribute(c);for(var d in c)if(c[u](d)){var e=v(c[d]);e?"xlink:"==d.substring(0,6)?a.setAttributeNS(T,d.substring(6),e):a.setAttribute(d,e):a.removeAttribute(d)}}else a=t.doc.createElementNS("http://www.w3.org/2000/svg",a);return a}function c(a,b){return b=v.prototype.toLowerCase.call(b),"finite"==b?!H[u](+a):"array"==b&&(a instanceof Array||Array.isArray&&Array.isArray(a))?!0:"null"==b&&null===a||b==typeof a&&null!==a||"object"==b&&a===Object(a)||F.call(a).slice(8,-1).toLowerCase()==b}function d(a){if("function"==typeof a||Object(a)!==a)return a;var b=new a.constructor;for(var c in a)a[u](c)&&(b[c]=d(a[c]));return b}function e(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return a.push(a.splice(c,1)[0])}function f(a,b,c){function d(){var f=Array.prototype.slice.call(arguments,0),g=f.join("␀"),h=d.cache=d.cache||{},i=d.count=d.count||[];return h[u](g)?(e(i,g),c?c(h[g]):h[g]):(i.length>=1e3&&delete h[i.shift()],i.push(g),h[g]=a.apply(b,f),c?c(h[g]):h[g])}return d}function g(a){return a%360*C/180}function h(a){return 180*a/C%360}function i(){return this.x+E+this.y+E+this.width+" × "+this.height}function j(a,b,c,d,e,f){return null==b&&"[object SVGMatrix]"==F.call(a)?(this.a=a.a,this.b=a.b,this.c=a.c,this.d=a.d,this.e=a.e,this.f=a.f,void 0):(null!=a?(this.a=+a,this.b=+b,this.c=+c,this.d=+d,this.e=+e,this.f=+f):(this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0),void 0)}function k(a){var b=[];return a=a.replace(/(?:^|\s)(\w+)\(([^)]+)\)/g,function(a,c,d){return d=d.split(/\s*,\s*/),"rotate"==c&&1==d.length&&d.push(0,0),"scale"==c&&(2==d.length&&d.push(0,0),1==d.length&&d.push(d[0],0,0)),"skewX"==c?b.push(["m",1,0,y.tan(g(d[0])),1,0,0]):"skewY"==c?b.push(["m",1,y.tan(g(d[0])),0,1,0,0]):b.push([c.charAt(0)].concat(d)),a}),b}function l(a,b){if(null==b){var c=!0;if(b="linearGradient"==a.type||"radialGradient"==a.type?a.node.getAttribute("gradientTransform"):"pattern"==a.type?a.node.getAttribute("patternTransform"):a.node.getAttribute("transform"),!b)return new j;b=k(b)}else b=bb.test(b)?v(b).replace(/\.{3}|\u2026/g,a._.transform||D):k(b);var d=ab(b),e=0,f=0,g=0,h=1,i=1,l=a._,m=new j;if(l.transform=d||[],d){for(var n=0,o=d.length;o>n;n++){var p,q,r,s,t,u=d[n],w=u.length,x=v(u[0]).toLowerCase(),y=u[0]!=x,z=y?m.invert():0;"t"==x&&3==w?y?(p=z.x(0,0),q=z.y(0,0),r=z.x(u[1],u[2]),s=z.y(u[1],u[2]),m.translate(r-p,s-q)):m.translate(u[1],u[2]):"r"==x?2==w?(t=t||a.getBBox(1),m.rotate(u[1],t.x+t.width/2,t.y+t.height/2),e+=u[1]):4==w&&(y?(r=z.x(u[2],u[3]),s=z.y(u[2],u[3]),m.rotate(u[1],r,s)):m.rotate(u[1],u[2],u[3]),e+=u[1]):"s"==x?2==w||3==w?(t=t||a.getBBox(1),m.scale(u[1],u[w-1],t.x+t.width/2,t.y+t.height/2),h*=u[1],i*=u[w-1]):5==w&&(y?(r=z.x(u[3],u[4]),s=z.y(u[3],u[4]),m.scale(u[1],u[2],r,s)):m.scale(u[1],u[2],u[3],u[4]),h*=u[1],i*=u[2]):"m"==x&&7==w&&m.add(u[1],u[2],u[3],u[4],u[5],u[6])}if(c)return m;l.dirtyT=1,a.matrix=m}a.matrix=m,l.sx=h,l.sy=i,l.deg=e,l.dx=f=m.e,l.dy=g=m.f,1==h&&1==i&&!e&&l.bbox?(l.bbox.x+=+f,l.bbox.y+=+g):l.dirtyT=1}function m(a,c,d){function e(a){return null==a?D:a==+a?a:(b(j,{width:a}),j.getBBox().width)}function f(a){return null==a?D:a==+a?a:(b(j,{height:a}),j.getBBox().height)}function g(b,e){null==c?i[b]=e(a.attr(b)):b==c&&(i=e(null==d?a.attr(b):d))}var h=a.paper.defs,i={},j=a.paper.measurer;switch(j||(a.paper.measurer=j=b("rect"),b(j,{width:10,height:10}),h.appendChild(j)),a.type){case"rect":g("rx",e),g("ry",f);case"image":g("width",e),g("height",f);case"text":g("x",e),g("y",f);break;case"circle":g("cx",e),g("cy",f),g("r",e);break;case"ellipse":g("cx",e),g("cy",f),g("rx",e),g("ry",f);break;case"line":g("x1",e),g("x2",e),g("y1",f),g("y2",f);break;case"marker":g("refX",e),g("markerWidth",e),g("refY",f),g("markerHeight",f);break;case"radialGradient":g("fx",e),g("fy",f);break;case"tspan":g("dx",e),g("dy",f);break;default:i=null}return i}function n(a){if(a.savage in U)return U[a.savage];var b,c=this.id=S();try{b=a.ownerSVGElement}catch(d){}this.node=a,b&&(this.paper=new r(b)),this.type=a.tagName,this._={transform:[],sx:1,sy:1,deg:0,dx:0,dy:0,dirty:1},a.savage=c,U[c]=this}function o(a){for(var b,c=0,d=a.length;d>c;c++)if(b=b||a[c])return b}function p(a){this.node=a}function q(a,c){var d=b(a);c.appendChild(d);var e=s(d);return e.type=a,e}function r(a,c){var d,e,f,g=r.prototype;if(a&&"svg"==a.tagName){if(a.savage in U)return U[a.savage];d=new n(a),e=a.getElementsByTagName("desc")[0],f=a.getElementsByTagName("defs")[0]}else d=q("svg",t.doc.body),b(d.node,{height:c,version:1.1,width:a,xmlns:"http://www.w3.org/2000/svg"});e||(e=b("desc"),e.appendChild(t.doc.createTextNode("Created with Savage")),d.node.appendChild(e)),f||(f=b("defs"),d.node.appendChild(f));for(var h in g)g[u](h)&&(d[h]=g[h]);return d.paper=d,d.defs=f,d}function s(a){return a?a instanceof n||a instanceof p?a:"svg"==a.tagName?new r(a):new n(a):a}a.version="0.0.1",a.toString=function(){return"Savage v"+this.version},a._={};var t={win:window,doc:window.document},u="hasOwnProperty",v=String,w=parseFloat,x=parseInt,y=Math,z=y.max,A=y.min,B=y.abs,C=(y.pow,y.PI),D=(y.round,""),E=" ",F=Object.prototype.toString,G=/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i,H={NaN:1,Infinity:1,"-Infinity":1},I=/^url\(#?([^)]+)\)$/,J=" \n \f\r   ᠎              \u2028\u2029",K=new RegExp("[,"+J+"]+"),L=(new RegExp("["+J+"]","g"),new RegExp("["+J+"]*,["+J+"]*")),M={hs:1,rg:1},N=new RegExp("([a-z])["+J+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+J+"]*,?["+J+"]*)+)","ig"),O=new RegExp("([rstm])["+J+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+J+"]*,?["+J+"]*)+)","ig"),P=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+J+"]*,?["+J+"]*","ig"),Q=0,R="S"+(+new Date).toString(36),S=function(){return R+(Q++).toString(36)},T="http://www.w3.org/1999/xlink",U={};a._.$=b;var V=function(){function a(){this.parentNode.removeChild(this)}return function(b,c){var d=t.doc.createElement("img"),e=t.doc.body;d.style.cssText="position:absolute;left:-9999em;top:-9999em",d.onload=function(){c.call(d),d.onload=d.onerror=null,e.removeChild(d)},d.onerror=a,e.appendChild(d),d.src=b}}();a._.clone=d,a._.cacher=f,a.rad=g,a.deg=h,a.is=c,a.snapTo=function(a,b,d){if(d=c(d,"finite")?d:10,c(a,"array")){for(var e=a.length;e--;)if(B(a[e]-b)<=d)return a[e]}else{a=+a;var f=b%a;if(d>f)return b-f;if(f>a-d)return b-f+a}return b},function(a){function b(a){return a[0]*a[0]+a[1]*a[1]}function c(a){var c=y.sqrt(b(a));a[0]&&(a[0]/=c),a[1]&&(a[1]/=c)}a.add=function(a,b,c,d,e,f){var g,h,i,k,l=[[],[],[]],m=[[this.a,this.c,this.e],[this.b,this.d,this.f],[0,0,1]],n=[[a,c,e],[b,d,f],[0,0,1]];for(a&&a instanceof j&&(n=[[a.a,a.c,a.e],[a.b,a.d,a.f],[0,0,1]]),g=0;3>g;g++)for(h=0;3>h;h++){for(k=0,i=0;3>i;i++)k+=m[g][i]*n[i][h];l[g][h]=k}return this.a=l[0][0],this.b=l[1][0],this.c=l[0][1],this.d=l[1][1],this.e=l[0][2],this.f=l[1][2],this},a.invert=function(){var a=this,b=a.a*a.d-a.b*a.c;return new j(a.d/b,-a.b/b,-a.c/b,a.a/b,(a.c*a.f-a.d*a.e)/b,(a.b*a.e-a.a*a.f)/b)},a.clone=function(){return new j(this.a,this.b,this.c,this.d,this.e,this.f)},a.translate=function(a,b){return this.add(1,0,0,1,a,b)},a.scale=function(a,b,c,d){return null==b&&(b=a),(c||d)&&this.add(1,0,0,1,c,d),this.add(a,0,0,b,0,0),(c||d)&&this.add(1,0,0,1,-c,-d),this},a.rotate=function(a,b,c){a=g(a),b=b||0,c=c||0;var d=+y.cos(a).toFixed(9),e=+y.sin(a).toFixed(9);return this.add(d,e,-e,d,b,c),this.add(1,0,0,1,-b,-c)},a.x=function(a,b){return a*this.a+b*this.c+this.e},a.y=function(a,b){return a*this.b+b*this.d+this.f},a.get=function(a){return+this[v.fromCharCode(97+a)].toFixed(4)},a.toString=function(){return"matrix("+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)].join()+")"},a.offset=function(){return[this.e.toFixed(4),this.f.toFixed(4)]},a.split=function(){var a={};a.dx=this.e,a.dy=this.f;var d=[[this.a,this.c],[this.b,this.d]];a.scalex=y.sqrt(b(d[0])),c(d[0]),a.shear=d[0][0]*d[1][0]+d[0][1]*d[1][1],d[1]=[d[1][0]-d[0][0]*a.shear,d[1][1]-d[0][1]*a.shear],a.scaley=y.sqrt(b(d[1])),c(d[1]),a.shear/=a.scaley;var e=-d[0][1],f=d[1][1];return 0>f?(a.rotate=h(y.acos(f)),0>e&&(a.rotate=360-a.rotate)):a.rotate=h(y.asin(e)),a.isSimple=!(+a.shear.toFixed(9)||a.scalex.toFixed(9)!=a.scaley.toFixed(9)&&a.rotate),a.isSuperSimple=!+a.shear.toFixed(9)&&a.scalex.toFixed(9)==a.scaley.toFixed(9)&&!a.rotate,a.noRotation=!+a.shear.toFixed(9)&&!a.rotate,a},a.toTransformString=function(a){var b=a||this.split();return b.isSimple?(b.scalex=+b.scalex.toFixed(4),b.scaley=+b.scaley.toFixed(4),b.rotate=+b.rotate.toFixed(4),(b.dx||b.dy?"t"+[+b.dx.toFixed(4),+b.dy.toFixed(4)]:D)+(1!=b.scalex||1!=b.scaley?"s"+[b.scalex,b.scaley,0,0]:D)+(b.rotate?"r"+[+b.rotate.toFixed(4),0,0]:D)):"m"+[this.get(0),this.get(1),this.get(2),this.get(3),this.get(4),this.get(5)]}}(j.prototype),a.Matrix=j,a.getRGB=f(function(b){if(!b||(b=v(b)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1,toString:Z};if("none"==b)return{r:-1,g:-1,b:-1,hex:"none",toString:Z};!(M[u](b.toLowerCase().substring(0,2))||"#"==b.charAt())&&(b=W(b));var d,e,f,g,h,i,j=b.match(G);return j?(j[2]&&(f=x(j[2].substring(5),16),e=x(j[2].substring(3,5),16),d=x(j[2].substring(1,3),16)),j[3]&&(f=x((h=j[3].charAt(3))+h,16),e=x((h=j[3].charAt(2))+h,16),d=x((h=j[3].charAt(1))+h,16)),j[4]&&(i=j[4].split(L),d=w(i[0]),"%"==i[0].slice(-1)&&(d*=2.55),e=w(i[1]),"%"==i[1].slice(-1)&&(e*=2.55),f=w(i[2]),"%"==i[2].slice(-1)&&(f*=2.55),"rgba"==j[1].toLowerCase().slice(0,4)&&(g=w(i[3])),i[3]&&"%"==i[3].slice(-1)&&(g/=100)),j[5]?(i=j[5].split(L),d=w(i[0]),"%"==i[0].slice(-1)&&(d*=2.55),e=w(i[1]),"%"==i[1].slice(-1)&&(e*=2.55),f=w(i[2]),"%"==i[2].slice(-1)&&(f*=2.55),("deg"==i[0].slice(-3)||"°"==i[0].slice(-1))&&(d/=360),"hsba"==j[1].toLowerCase().slice(0,4)&&(g=w(i[3])),i[3]&&"%"==i[3].slice(-1)&&(g/=100),a.hsb2rgb(d,e,f,g)):j[6]?(i=j[6].split(L),d=w(i[0]),"%"==i[0].slice(-1)&&(d*=2.55),e=w(i[1]),"%"==i[1].slice(-1)&&(e*=2.55),f=w(i[2]),"%"==i[2].slice(-1)&&(f*=2.55),("deg"==i[0].slice(-3)||"°"==i[0].slice(-1))&&(d/=360),"hsla"==j[1].toLowerCase().slice(0,4)&&(g=w(i[3])),i[3]&&"%"==i[3].slice(-1)&&(g/=100),a.hsl2rgb(d,e,f,g)):(j={r:d,g:e,b:f,toString:Z},j.hex="#"+(16777216|f|e<<8|d<<16).toString(16).slice(1),c(g,"finite")&&(j.opacity=g),j)):{r:-1,g:-1,b:-1,hex:"none",error:1,toString:Z}},a),a.hsb=f(function(b,c,d){return a.hsb2rgb(b,c,d).hex}),a.hsl=f(function(b,c,d){return a.hsl2rgb(b,c,d).hex}),a.rgb=f(function(a,b,d,e){if(c(e,"finite")){var f=y.round;return"rgba("+[f(a),f(b),f(d),+e.toFixed(2)]+")"}return"#"+(16777216|d|b<<8|a<<16).toString(16).slice(1)});var W=function(a){var b=t.doc.getElementsByTagName("head")[0];return W=f(function(a){b.style.color="inherit",b.style.color=a;var c=t.doc.defaultView.getComputedStyle(b,D).getPropertyValue("color");return"inherit"==c?null:c}),W(a)},X=function(){return"hsb("+[this.h,this.s,this.b]+")"},Y=function(){return"hsl("+[this.h,this.s,this.l]+")"},Z=function(){return 1==this.opacity||null==this.opacity?this.hex:"rgba("+[this.r,this.g,this.b,this.opacity]+")"},$=function(b,d,e){if(null==d&&c(b,"object")&&"r"in b&&"g"in b&&"b"in b&&(e=b.b,d=b.g,b=b.r),null==d&&c(b,string)){var f=a.getRGB(b);b=f.r,d=f.g,e=f.b}return(b>1||d>1||e>1)&&(b/=255,d/=255,e/=255),[b,d,e]},_=function(b,d,e,f){b=y.round(255*b),d=y.round(255*d),e=y.round(255*e);var g={r:b,g:d,b:e,hex:a.rgb(b,d,e),toString:Z};return c(f,"finite")&&(g.opacity=f),g};a.color=function(b){var d;return c(b,"object")&&"h"in b&&"s"in b&&"b"in b?(d=a.hsb2rgb(b),b.r=d.r,b.g=d.g,b.b=d.b,b.hex=d.hex):c(b,"object")&&"h"in b&&"s"in b&&"l"in b?(d=a.hsl2rgb(b),b.r=d.r,b.g=d.g,b.b=d.b,b.hex=d.hex):(c(b,"string")&&(b=a.getRGB(b)),c(b,"object")&&"r"in b&&"g"in b&&"b"in b?(d=a.rgb2hsl(b),b.h=d.h,b.s=d.s,b.l=d.l,d=a.rgb2hsb(b),b.v=d.b):(b={hex:"none"},b.r=b.g=b.b=b.h=b.s=b.v=b.l=-1)),b.toString=Z,b},a.hsb2rgb=function(a,b,d,e){c(a,"object")&&"h"in a&&"s"in a&&"b"in a&&(d=a.b,b=a.s,a=a.h,e=a.o),a*=360;var f,g,h,i,j;return a=a%360/60,j=d*b,i=j*(1-B(a%2-1)),f=g=h=d-j,a=~~a,f+=[j,i,0,0,i,j][a],g+=[i,j,j,i,0,0][a],h+=[0,0,i,j,j,i][a],_(f,g,h,e)},a.hsl2rgb=function(a,b,d,e){c(a,"object")&&"h"in a&&"s"in a&&"l"in a&&(d=a.l,b=a.s,a=a.h),(a>1||b>1||d>1)&&(a/=360,b/=100,d/=100),a*=360;var f,g,h,i,j;return a=a%360/60,j=2*b*(.5>d?d:1-d),i=j*(1-B(a%2-1)),f=g=h=d-j/2,a=~~a,f+=[j,i,0,0,i,j][a],g+=[i,j,j,i,0,0][a],h+=[0,0,i,j,j,i][a],_(f,g,h,e)},a.rgb2hsb=function(a,b,c){c=$(a,b,c),a=c[0],b=c[1],c=c[2];var d,e,f,g;return f=z(a,b,c),g=f-A(a,b,c),d=0==g?null:f==a?(b-c)/g:f==b?(c-a)/g+2:(a-b)/g+4,d=60*((d+360)%6)/360,e=0==g?0:g/f,{h:d,s:e,b:f,toString:X}},a.rgb2hsl=function(a,b,c){c=$(a,b,c),a=c[0],b=c[1],c=c[2];var d,e,f,g,h,i;return g=z(a,b,c),h=A(a,b,c),i=g-h,d=0==i?null:g==a?(b-c)/i:g==b?(c-a)/i+2:(a-b)/i+4,d=60*((d+360)%6)/360,f=(g+h)/2,e=0==i?0:.5>f?i/(2*f):i/(2-2*f),{h:d,s:e,l:f,toString:Y}},a.parsePathString=function(b){if(!b)return null;var d=a.path(b);if(d.arr)return a.path.clone(d.arr);var e={a:7,c:6,o:2,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,u:3,z:0},f=[];return c(b,"array")&&c(b[0],"array")&&(f=a.path.clone(b)),f.length||v(b).replace(N,function(a,b,c){var d=[],g=b.toLowerCase();if(c.replace(P,function(a,b){b&&d.push(+b)}),"m"==g&&d.length>2&&(f.push([b].concat(d.splice(0,2))),g="l",b="m"==b?"l":"L"),"o"==g&&1==d.length&&f.push([b,d[0]]),"r"==g)f.push([b].concat(d));else for(;d.length>=e[g]&&(f.push([b].concat(d.splice(0,e[g]))),e[g]););}),f.toString=a.path.toString,d.arr=a.path.clone(f),f};var ab=a.parseTransformString=function(b){if(!b)return null;var d=[];return c(b,"array")&&c(b[0],"array")&&(d=a.path.clone(b)),d.length||v(b).replace(O,function(a,b,c){var e=[];b.toLowerCase(),c.replace(P,function(a,b){b&&e.push(+b)}),d.push([b].concat(e))}),d.toString=a.path.toString,d},bb=new RegExp("^[a-z]["+J+"]*-?\\.?\\d");a.select=function(a){return s(t.doc.querySelector(a))},a.selectAll=function(b){for(var c=t.doc.querySelectorAll(b),d=(a.set||Array)(),e=0;ed;d++){var f=b[d];f.node&&f.node.nodeType&&c.appendChild(f.node),f.nodeType&&c.appendChild(f),"string"==typeof f&&c.appendChild(a.parse(f))}return new p(c)},function(d){function e(a){c(a,"array")||(a=Array.prototype.slice.call(arguments,0));for(var b=0,d=0,e=this.node;this[b];)delete this[b++];for(b=0;b1&&(a=Array.prototype.slice.call(arguments,0));var b=q("polyline",this.node);return c(a,"object")&&!c(a,"array")?b.attr(a):null!=a&&b.attr({points:a}),b},d.polygon=function(a){arguments.length>1&&(a=Array.prototype.slice.call(arguments,0));var b=q("polygon",this.node);return c(a,"object")&&!c(a,"array")?b.attr(a):null!=a&&b.attr({points:a}),b},function(){function c(){return this.selectAll("stop")}function e(a,c){var d=b("stop");return b(d,{"stop-color":a,offset:+c+"%"}),this.node.appendChild(d),this}function f(){if("linearGradient"==this.type){var c=b(this.node,"x1")||0,d=b(this.node,"x2")||1,e=b(this.node,"y1")||0,f=b(this.node,"y2")||0;return a._.box(c,e,y.abs(d-c),y.abs(f-e))}var g=this.node.cx||.5,h=this.node.cy||.5,i=this.node.r||0;return a._.box(g-i,h-i,2*i,2*i)}d.gradient=function(a){function c(a,b){for(var c=(b-h)/(a-i),d=i;a>d;d++)f[d].offset=+(+h+c*(d-i)).toFixed(2);i=a,h=b}var d,e=o(eve("savage.util.grad.parse",null,a));d="l"==e.type.toLowerCase()?this.gradientLinear.apply(this,e.params):this.gradientRadial.apply(this,e.params),e.type!=e.type.toLowerCase()&&b(d.node,{gradientUnits:"userSpaceOnUse"});var f=e.stops,g=f.length,h=0,i=0;g--;for(var j=0;g>j;j++)"offset"in f[j]&&c(j,f[j].offset);for(f[g].offset=f[g].offset||100,c(g,f[g].offset),j=0;g>=j;j++){var k=f[j];d.addStop(k.color,k.offset)}return d},d.gradientLinear=function(a,d,g,h){var i=q("linearGradient",this.node);return i.stops=c,i.addStop=e,i.getBBox=f,null!=a&&b(i.node,{x1:a,y1:d,x2:g,y2:h}),i},d.gradientRadial=function(a,d,g,h,i){var j=q("radialGradient",this.node);return j.stops=c,j.addStop=e,j.getBBox=f,null!=a&&b(j.node,{cx:a,cy:d,r:g}),null!=h&&null!=i&&b(j.node,{fx:h,fy:i}),j}}()}(r.prototype),eve.on("savage.util.attr.mask",function(a){if(a instanceof n||a instanceof p){if(eve.stop(),a instanceof p&&1==a.node.childNodes.length&&(a=a.node.firstChild,this.paper.defs.appendChild(a),a=s(a)),"mask"==a.type)var c=a;else c=q("mask",this.paper.defs),c.node.appendChild(a.node),!c.node.id&&b(c.node,{id:c.id});b(this.node,{mask:"url(#"+c.id+")"})}}),function(a){eve.on("savage.util.attr.clip",a),eve.on("savage.util.attr.clip-path",a),eve.on("savage.util.attr.clipPath",a)}(function(a){if(a instanceof n||a instanceof p){if(eve.stop(),"clipPath"==a.type)var c=a;else c=q("clipPath",this.paper.defs),c.node.appendChild(a.node),!c.node.id&&b(c.node,{id:c.id});b(this.node,{"clip-path":"url(#"+c.id+")"})}}),eve.on("savage.util.attr.fill",function(c){if(eve.stop(),c instanceof p&&1==c.node.childNodes.length&&("radialGradient"==c.node.firstChild.tagName||"linearGradient"==c.node.firstChild.tagName||"pattern"==c.node.firstChild.tagName)&&(c=c.node.firstChild,this.paper.defs.appendChild(c),c=s(c)),c instanceof n&&("radialGradient"==c.type||"linearGradient"==c.type||"pattern"==c.type)){c.node.id||b(c.node,{id:c.id}); var d="url(#"+c.node.id+")"}else if(d=a.color(c),d.error){var e=this.paper.gradient(c);e.node.id||b(e.node,{id:e.id}),d="url(#"+e.node.id+")"}else d=v(d);b(this.node,{fill:d}),this.node.style.fill=D});var cb=/^([lr])(?:\(([^)]*)\))?(.*)$/i;eve.on("savage.util.grad.parse",function(a){a=v(a);var b=a.match(cb),c=b[1],d=b[2],e=b[3];return d=d.split(/\s*,\s*/).map(function(a){return+a==a?+a:a}),1==d.length&&0==d[0]&&(d=[]),e=e.split("-"),e=e.map(function(a){a=a.split(":");var b={color:a[0]};return a[1]&&(b.offset=a[1]),b}),{type:c,params:d,stops:e}}),eve.on("savage.util.attr.d",function(d){eve.stop(),c(d,"array")&&c(d[0],"array")&&(d=a.path.toString.call(d)),d=v(d),d.match(/[ruo]/i)&&(d=a.path.toAbsolute(d)),b(this.node,{d:d})})(-1),eve.on("savage.util.attr.path",function(a){eve.stop(),this.attr({d:a})})(-1),eve.on("savage.util.attr.viewBox",function(a){var d;d=c(a,"object")&&"x"in a?[a.x,a.y,a.width,a.height].join(" "):c(a,"array")?a.join(" "):a,b(this.node,{viewBox:d}),eve.stop()})(-1),eve.on("savage.util.attr.transform",function(a){this.transform(a),eve.stop()})(-1),eve.on("savage.util.attr.r",function(a){"rect"==this.type&&(eve.stop(),b(this.node,{rx:a,ry:a}))})(-1),eve.on("savage.util.attr.text",function(a){if("text"==this.type){for(var d=this.node,e=function(a){var d=b("tspan");if(c(a,"array"))for(var f=0;fq;q++){if(k=d[q],"M"==k[0])h=+k[1],j=+k[2];else{if(l=g(h,j,k[1],k[2],k[3],k[4],k[5],k[6]),p+l>e){if(b&&!o.start){if(m=g(h,j,k[1],k[2],k[3],k[4],k[5],k[6],e-p),n+=["C"+c(m.start.x),c(m.start.y),c(m.m.x),c(m.m.y),c(m.x),c(m.y)],f)return n;o.start=n,n=["M"+c(m.x),c(m.y)+"C"+c(m.n.x),c(m.n.y),c(m.end.x),c(m.end.y),c(k[5]),c(k[6])].join(),p+=l,h=+k[5],j=+k[6];continue}if(!a&&!b)return m=g(h,j,k[1],k[2],k[3],k[4],k[5],k[6],e-p)}p+=l,h=+k[5],j=+k[6]}n+=k.shift()+k}return o.end=n,m=a?p:b?o:i(h,j,k[0],k[1],k[2],k[3],k[4],k[5],1)}}function i(a,b,c,d,e,f,g,h,i){var j=1-i,k=S(j,3),l=S(j,2),m=i*i,n=m*i,o=k*a+3*l*i*c+3*j*i*i*e+n*g,p=k*b+3*l*i*d+3*j*i*i*f+n*h,q=a+2*i*(c-a)+m*(e-2*c+a),r=b+2*i*(d-b)+m*(f-2*d+b),s=c+2*i*(e-c)+m*(g-2*e+c),t=d+2*i*(f-d)+m*(h-2*f+d),u=j*a+i*c,v=j*b+i*d,w=j*e+i*g,x=j*f+i*h,y=90-180*O.atan2(q-s,r-t)/P;return{x:o,y:p,m:{x:q,y:r},n:{x:s,y:t},start:{x:u,y:v},end:{x:w,y:x},alpha:y}}function j(b,c,e,f,g,h,i,j){a.is(b,"array")||(b=[b,c,e,f,g,h,i,j]);var k=E.apply(null,b);return d(k.min.x,k.min.y,k.max.x-k.min.x,k.max.y-k.min.y)}function k(a,b,c){return b>=a.x&&b<=a.x+a.width&&c>=a.y&&c<=a.y+a.height}function l(a,b){return a=d(a),b=d(b),k(b,a.x,a.y)||k(b,a.x2,a.y)||k(b,a.x,a.y2)||k(b,a.x2,a.y2)||k(a,b.x,b.y)||k(a,b.x2,b.y)||k(a,b.x,b.y2)||k(a,b.x2,b.y2)||(a.xb.x||b.xa.x)&&(a.yb.y||b.ya.y)}function m(a,b,c,d,e){var f=-3*b+9*c-9*d+3*e,g=a*f+6*b-12*c+6*d;return a*g-3*b+3*c}function n(a,b,c,d,e,f,g,h,i){null==i&&(i=1),i=i>1?1:0>i?0:i;for(var j=i/2,k=12,l=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],n=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],o=0,p=0;k>p;p++){var q=j*l[p]+j,r=m(q,a,c,e,g),s=m(q,b,d,f,h),t=r*r+s*s;o+=n[p]*O.sqrt(t)}return j*o}function o(a,b,c,d,e,f,g,h,i){if(!(0>i||n(a,b,c,d,e,f,g,h)o;)l/=2,m+=(i>j?1:-1)*l,j=n(a,b,c,d,e,f,g,h,m);return m}}function p(a,b,c,d,e,f,g,h){if(!(R(a,c)R(e,g)||R(b,d)R(f,h))){var i=(a*d-b*c)*(e-g)-(a-c)*(e*h-f*g),j=(a*d-b*c)*(f-h)-(b-d)*(e*h-f*g),k=(a-c)*(f-h)-(b-d)*(e-g);if(k){var l=i/k,m=j/k,n=+l.toFixed(2),o=+m.toFixed(2);if(!(n<+Q(a,c).toFixed(2)||n>+R(a,c).toFixed(2)||n<+Q(e,g).toFixed(2)||n>+R(e,g).toFixed(2)||o<+Q(b,d).toFixed(2)||o>+R(b,d).toFixed(2)||o<+Q(f,h).toFixed(2)||o>+R(f,h).toFixed(2)))return{x:l,y:m}}}}function q(a,b,c){var d=j(a),e=j(b);if(!l(d,e))return c?0:[];for(var f=n.apply(0,a),g=n.apply(0,b),h=~~(f/5),k=~~(g/5),m=[],o=[],q={},r=c?0:[],s=0;h+1>s;s++){var t=i.apply(0,a.concat(s/h));m.push({x:t.x,y:t.y,t:s/h})}for(s=0;k+1>s;s++)t=i.apply(0,b.concat(s/k)),o.push({x:t.x,y:t.y,t:s/k});for(s=0;h>s;s++)for(var u=0;k>u;u++){var v=m[s],w=m[s+1],x=o[u],y=o[u+1],z=T(w.x-v.x)<.001?"y":"x",A=T(y.x-x.x)<.001?"y":"x",B=p(v.x,v.y,w.x,w.y,x.x,x.y,y.x,y.y);if(B){if(q[B.x.toFixed(4)]==B.y.toFixed(4))continue;q[B.x.toFixed(4)]=B.y.toFixed(4);var C=v.t+T((B[z]-v[z])/(w[z]-v[z]))*(w.t-v.t),D=x.t+T((B[A]-x[A])/(y[A]-x[A]))*(y.t-x.t);C>=0&&1>=C&&D>=0&&1>=D&&(c?r++:r.push({x:B.x,y:B.y,t1:C,t2:D}))}}return r}function r(a,b){return t(a,b)}function s(a,b){return t(a,b,1)}function t(a,b,c){a=F(a),b=F(b);for(var d,e,f,g,h,i,j,k,l,m,n=c?0:[],o=0,p=a.length;p>o;o++){var r=a[o];if("M"==r[0])d=h=r[1],e=i=r[2];else{"C"==r[0]?(l=[d,e].concat(r.slice(1)),d=l[6],e=l[7]):(l=[d,e,d,e,h,i,h,i],d=h,e=i);for(var s=0,t=b.length;t>s;s++){var u=b[s];if("M"==u[0])f=j=u[1],g=k=u[2];else{"C"==u[0]?(m=[f,g].concat(u.slice(1)),f=m[6],g=m[7]):(m=[f,g,f,g,j,k,j,k],f=j,g=k);var v=q(l,m,c);if(c)n+=v;else{for(var w=0,x=v.length;x>w;w++)v[w].segment1=o,v[w].segment2=s,v[w].bez1=l,v[w].bez2=m;n=n.concat(v)}}}}}return n}function u(a,b,c){var d=v(a);return k(d,b,c)&&1==t(a,[["M",b,c],["H",d.x2+10]],1)%2}function v(a){var b=c(a);if(b.bbox)return K(b.bbox);if(!a)return d();a=F(a);for(var e,f=0,g=0,h=[],i=[],j=0,k=a.length;k>j;j++)if(e=a[j],"M"==e[0])f=e[1],g=e[2],h.push(f),i.push(g);else{var l=E(f,g,e[1],e[2],e[3],e[4],e[5],e[6]);h=h.concat(l.min.x,l.max.x),i=i.concat(l.min.y,l.max.y),f=e[5],g=e[6]}var m=Q.apply(0,h),n=Q.apply(0,i),o=R.apply(0,h),p=R.apply(0,i),q=d(m,n,o-m,p-n);return b.bbox=K(q),q}function w(a,b,c,d,f){if(f)return[["M",a+f,b],["l",c-2*f,0],["a",f,f,0,0,1,f,f],["l",0,d-2*f],["a",f,f,0,0,1,-f,f],["l",2*f-c,0],["a",f,f,0,0,1,-f,-f],["l",0,2*f-d],["a",f,f,0,0,1,f,-f],["z"]];var g=[["M",a,b],["l",c,0],["l",0,d],["l",-c,0],["z"]];return g.toString=e,g}function x(a,b,c,d,f){if(null==f&&null==d&&(d=c),null!=f)var g=Math.PI/180,h=a+c*Math.cos(-d*g),i=a+c*Math.cos(-f*g),j=b+c*Math.sin(-d*g),k=b+c*Math.sin(-f*g),l=[["M",h,j],["A",c,c,0,+(f-d>180),0,i,k]];else l=[["M",a,b],["m",0,-d],["a",c,d,0,1,1,0,2*d],["a",c,d,0,1,1,0,-2*d],["z"]];return l.toString=e,l}function y(b){var d=c(b);if(d.rel)return f(d.rel);a.is(b,"array")&&a.is(b&&b[0],"array")||(b=a.parsePathString(b));var g=[],h=0,i=0,j=0,k=0,l=0;"M"==b[0][0]&&(h=b[0][1],i=b[0][2],j=h,k=i,l++,g.push(["M",h,i]));for(var m=l,n=b.length;n>m;m++){var o=g[m]=[],p=b[m];if(p[0]!=lowerCase.call(p[0]))switch(o[0]=lowerCase.call(p[0]),o[0]){case"a":o[1]=p[1],o[2]=p[2],o[3]=p[3],o[4]=p[4],o[5]=p[5],o[6]=+(p[6]-h).toFixed(3),o[7]=+(p[7]-i).toFixed(3);break;case"v":o[1]=+(p[1]-i).toFixed(3);break;case"m":j=p[1],k=p[2];default:for(var q=1,r=p.length;r>q;q++)o[q]=+(p[q]-(q%2?h:i)).toFixed(3)}else{o=g[m]=[],"m"==p[0]&&(j=p[1]+h,k=p[2]+i);for(var s=0,t=p.length;t>s;s++)g[m][s]=p[s]}var u=g[m].length;switch(g[m][0]){case"z":h=j,i=k;break;case"h":h+=+g[m][u-1];break;case"v":i+=+g[m][u-1];break;default:h+=+g[m][u-2],i+=+g[m][u-1]}}return g.toString=e,d.rel=f(g),g}function z(b){var d=c(b);if(d.abs)return f(d.abs);if(J(b,"array")&&J(b&&b[0],"array")||(b=a.parsePathString(b)),!b||!b.length)return[["M",0,0]];var g,h=[],i=0,j=0,k=0,l=0,m=0;"M"==b[0][0]&&(i=+b[0][1],j=+b[0][2],k=i,l=j,m++,h[0]=["M",i,j]);for(var n,o,p=3==b.length&&"M"==b[0][0]&&"R"==b[1][0].toUpperCase()&&"Z"==b[2][0].toUpperCase(),q=m,r=b.length;r>q;q++){if(h.push(n=[]),o=b[q],g=o[0],g!=g.toUpperCase())switch(n[0]=g.toUpperCase(),n[0]){case"A":n[1]=o[1],n[2]=o[2],n[3]=o[3],n[4]=o[4],n[5]=o[5],n[6]=+(o[6]+i),n[7]=+(o[7]+j);break;case"V":n[1]=+o[1]+j;break;case"H":n[1]=+o[1]+i;break;case"R":for(var s=[i,j].concat(o.slice(1)),t=2,u=s.length;u>t;t++)s[t]=+s[t]+i,s[++t]=+s[t]+j;h.pop(),h=h.concat(H(s,p));break;case"O":h.pop(),s=x(i,j,o[1],o[2]),s.push(s[0]),h=h.concat(s);break;case"U":h.pop(),h=h.concat(x(i,j,o[1],o[2],o[3])),n=["U"].concat(h[h.length-1].slice(-2));break;case"M":k=+o[1]+i,l=+o[2]+j;default:for(t=1,u=o.length;u>t;t++)n[t]=+o[t]+(t%2?i:j)}else if("R"==g)s=[i,j].concat(o.slice(1)),h.pop(),h=h.concat(H(s,p)),n=["R"].concat(o.slice(-2));else if("O"==g)h.pop(),s=x(i,j,o[1],o[2]),s.push(s[0]),h=h.concat(s);else if("U"==g)h.pop(),h=h.concat(x(i,j,o[1],o[2],o[3])),n=["U"].concat(h[h.length-1].slice(-2));else for(var v=0,w=o.length;w>v;v++)n[v]=o[v];if(g=g.toUpperCase(),"O"!=g)switch(n[0]){case"Z":i=k,j=l;break;case"H":i=n[1];break;case"V":j=n[1];break;case"M":k=n[n.length-2],l=n[n.length-1];default:i=n[n.length-2],j=n[n.length-1]}}return h.toString=e,d.abs=f(h),h}function A(a,b,c,d){return[a,b,c,d,c,d]}function B(a,b,c,d,e,f){var g=1/3,h=2/3;return[g*a+h*c,g*b+h*d,g*e+h*c,g*f+h*d,e,f]}function C(a,b,c,d,e,f,g,h,i,j){var k,l=120*P/180,m=P/180*(+e||0),n=[],o=cacher(function(a,b,c){var d=a*O.cos(c)-b*O.sin(c),e=a*O.sin(c)+b*O.cos(c);return{x:d,y:e}});if(j)x=j[0],y=j[1],v=j[2],w=j[3];else{k=o(a,b,-m),a=k.x,b=k.y,k=o(h,i,-m),h=k.x,i=k.y;var p=(O.cos(P/180*e),O.sin(P/180*e),(a-h)/2),q=(b-i)/2,r=p*p/(c*c)+q*q/(d*d);r>1&&(r=O.sqrt(r),c=r*c,d=r*d);var s=c*c,t=d*d,u=(f==g?-1:1)*O.sqrt(T((s*t-s*q*q-t*p*p)/(s*q*q+t*p*p))),v=u*c*q/d+(a+h)/2,w=u*-d*p/c+(b+i)/2,x=O.asin(((b-w)/d).toFixed(9)),y=O.asin(((i-w)/d).toFixed(9));x=v>a?P-x:x,y=v>h?P-y:y,0>x&&(x=2*P+x),0>y&&(y=2*P+y),g&&x>y&&(x-=2*P),!g&&y>x&&(y-=2*P)}var z=y-x;if(T(z)>l){var A=y,B=h,D=i;y=x+l*(g&&y>x?1:-1),h=v+c*O.cos(y),i=w+d*O.sin(y),n=C(h,i,c,d,e,0,g,B,D,[y,A,v,w])}z=y-x;var E=O.cos(x),F=O.sin(x),G=O.cos(y),H=O.sin(y),I=O.tan(z/4),J=4/3*c*I,K=4/3*d*I,L=[a,b],M=[a+J*F,b-K*E],N=[h+J*H,i-K*G],Q=[h,i];if(M[0]=2*L[0]-M[0],M[1]=2*L[1]-M[1],j)return[M,N,Q].concat(n);n=[M,N,Q].concat(n).join().split(",");for(var R=[],S=0,U=n.length;U>S;S++)R[S]=S%2?o(n[S-1],n[S],m).y:o(n[S],n[S+1],m).x;return R}function D(a,b,c,d,e,f,g,h,i){var j=1-i;return{x:S(j,3)*a+3*S(j,2)*i*c+3*j*i*i*e+S(i,3)*g,y:S(j,3)*b+3*S(j,2)*i*d+3*j*i*i*f+S(i,3)*h}}function E(a,b,c,d,e,f,g,h){var i,j=e-2*c+a-(g-2*e+c),k=2*(c-a)-2*(e-c),l=a-c,m=(-k+O.sqrt(k*k-4*j*l))/2/j,n=(-k-O.sqrt(k*k-4*j*l))/2/j,o=[b,h],p=[a,g];return T(m)>"1e12"&&(m=.5),T(n)>"1e12"&&(n=.5),m>0&&1>m&&(i=D(a,b,c,d,e,f,g,h,m),p.push(i.x),o.push(i.y)),n>0&&1>n&&(i=D(a,b,c,d,e,f,g,h,n),p.push(i.x),o.push(i.y)),j=f-2*d+b-(h-2*f+d),k=2*(d-b)-2*(f-d),l=b-d,m=(-k+O.sqrt(k*k-4*j*l))/2/j,n=(-k-O.sqrt(k*k-4*j*l))/2/j,T(m)>"1e12"&&(m=.5),T(n)>"1e12"&&(n=.5),m>0&&1>m&&(i=D(a,b,c,d,e,f,g,h,m),p.push(i.x),o.push(i.y)),n>0&&1>n&&(i=D(a,b,c,d,e,f,g,h,n),p.push(i.x),o.push(i.y)),{min:{x:Q.apply(0,p),y:Q.apply(0,o)},max:{x:R.apply(0,p),y:R.apply(0,o)}}}function F(a,b){var d=!b&&c(a);if(!b&&d.curve)return f(d.curve);for(var e=z(a),g=b&&z(b),h={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},j=(function(a,b){var c,d;if(!a)return["C",b.x,b.y,b.x,b.y,b.x,b.y];switch(!(a[0]in{T:1,Q:1})&&(b.qx=b.qy=null),a[0]){case"M":b.X=a[1],b.Y=a[2];break;case"A":a=["C"].concat(C.apply(0,[b.x,b.y].concat(a.slice(1))));break;case"S":c=b.x+(b.x-(b.bx||b.x)),d=b.y+(b.y-(b.by||b.y)),a=["C",c,d].concat(a.slice(1));break;case"T":b.qx=b.x+(b.x-(b.qx||b.x)),b.qy=b.y+(b.y-(b.qy||b.y)),a=["C"].concat(B(b.x,b.y,b.qx,b.qy,a[1],a[2]));break;case"Q":b.qx=a[1],b.qy=a[2],a=["C"].concat(B(b.x,b.y,a[1],a[2],a[3],a[4]));break;case"L":a=["C"].concat(A(b.x,b.y,a[1],a[2]));break;case"H":a=["C"].concat(A(b.x,b.y,a[1],b.y));break;case"V":a=["C"].concat(A(b.x,b.y,b.x,a[1]));break;case"Z":a=["C"].concat(A(b.x,b.y,b.X,b.Y))}return a}),k=function(a,b){if(a[b].length>7){a[b].shift();for(var c=a[b];c.length;)a.splice(b++,0,["C"].concat(c.splice(0,6)));a.splice(b,1),n=R(e.length,g&&g.length||0)}},l=function(a,b,c,d,f){a&&b&&"M"==a[f][0]&&"M"!=b[f][0]&&(b.splice(f,0,["M",d.x,d.y]),c.bx=0,c.by=0,c.x=a[f][1],c.y=a[f][2],n=R(e.length,g&&g.length||0))},m=0,n=R(e.length,g&&g.length||0);n>m;m++){e[m]=j(e[m],h),k(e,m),g&&(g[m]=j(g[m],i)),g&&k(g,m),l(e,g,h,i,m),l(g,e,i,h,m);var o=e[m],p=g&&g[m],q=o.length,r=g&&p.length;h.x=o[q-2],h.y=o[q-1],h.bx=N(o[q-4])||h.x,h.by=N(o[q-3])||h.y,i.bx=g&&(N(p[r-4])||i.x),i.by=g&&(N(p[r-3])||i.y),i.x=g&&p[r-2],i.y=g&&p[r-1]}return g||(d.curve=f(e)),g?[e,g]:e}function G(a,b){if(!b)return a;var c,d,e,f,g,h,i;for(a=F(a),e=0,g=a.length;g>e;e++)for(i=a[e],f=1,h=i.length;h>f;f+=2)c=b.x(i[f],i[f+1]),d=b.y(i[f],i[f+1]),i[f]=c,i[f+1]=d;return a}function H(a,b){for(var c=[],d=0,e=a.length;e-2*!b>d;d+=2){var f=[{x:+a[d-2],y:+a[d-1]},{x:+a[d],y:+a[d+1]},{x:+a[d+2],y:+a[d+3]},{x:+a[d+4],y:+a[d+5]}];b?d?e-4==d?f[3]={x:+a[0],y:+a[1]}:e-2==d&&(f[2]={x:+a[0],y:+a[1]},f[3]={x:+a[2],y:+a[3]}):f[0]={x:+a[e-2],y:+a[e-1]}:e-4==d?f[3]=f[2]:d||(f[0]={x:+a[d],y:+a[d+1]}),c.push(["C",(-f[0].x+6*f[1].x+f[2].x)/6,(-f[0].y+6*f[1].y+f[2].y)/6,(f[1].x+6*f[2].x-f[3].x)/6,(f[1].y+6*f[2].y-f[3].y)/6,f[2].x,f[2].y])}return c}var I=b.prototype,J=a.is,K=a._.clone,L="hasOwnProperty",M=/,?([a-z]),?/gi,N=parseFloat,O=Math,P=O.PI,Q=O.min,R=O.max,S=O.pow,T=O.abs,U=h(1),V=h(),W=h(0,1),X={path:function(a){return a.attr("path")},circle:function(a){var b=unit2px(a);return x(b.cx,b.cy,b.r)},ellipse:function(a){var b=unit2px(a);return x(b.cx,b.cy,b.rx,b.ry)},rect:function(a){var b=unit2px(a);return w(b.x,b.y,b.width,b.height,b.rx,b.ry)},image:function(a){var b=unit2px(a);return w(b.x,b.y,b.width,b.height)},text:function(a){var b=a.node.getBBox();return w(b.x,b.y,b.width,b.height)},g:function(a){var b=a.node.getBBox();return w(b.x,b.y,b.width,b.height)},symbol:function(a){var b=a.getBBox();return w(b.x,b.y,b.width,b.height)}};a.path=c,a.path.getTotalLength=U,a.path.getPointAtLength=V,a.path.getSubpath=function(a,b,c){if(this.getTotalLength(a)-c<1e-6)return W(a,b).end;var d=W(a,c,1);return b?W(d,b).end:d},I.getTotalLength=function(){return this.node.getTotalLength?this.node.getTotalLength():void 0},I.getPointAtLength=function(a){return V(this.attr("d"),a)},I.getSubpath=function(a,b){return getSubpath(this.attr("d"),a,b)},a._.box=d,a.path.findDotsAtSegment=i,a.path.bezierBBox=j,a.path.isPointInsideBBox=k,a.path.isBBoxIntersect=l,a.path.intersection=r,a.path.intersectionNumber=s,a.path.isPointInside=u,a.path.getBBox=v,a.path.get=X,a.path.toRelative=y,a.path.toAbsolute=z,a.path.toCubic=F,a.path.map=G,a.path.toString=e,a.path.clone=f}),Savage.plugin(function(a){var b=Math.max,c=Math.min,d=function(a){if(this.items=[],this.length=0,this.type="set",a)for(var b=0,c=a.length;c>b;b++)a[b]&&(this[this.items.length]=this.items[this.items.length]=a[b],this.length++)},e=d.prototype;e.push=function(){for(var a,b,c=0,d=arguments.length;d>c;c++)a=arguments[c],a&&(b=this.items.length,this[b]=this.items[b]=a,this.length++);return this},e.pop=function(){return this.length&&delete this[this.length--],this.items.pop()},e.forEach=function(a,b){for(var c=0,d=this.items.length;d>c;c++)if(a.call(b,this.items[c],c)===!1)return this;return this},e.attr=function(a){for(var b=0,c=this.items.length;c>b;b++)this.items[b].attr(a);return this},e.clear=function(){for(;this.length;)this.pop()},e.splice=function(a,e){a=0>a?b(this.length+a,0):a,e=b(0,c(this.length-a,e));var f,g=[],h=[],i=[];for(f=2;ff;f++)h.push(this[a+f]);for(;ff?i[f]:g[f-j];for(f=this.items.length=this.length-=e-j;this[f];)delete this[f++];return new d(h)},e.exclude=function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]==a)return this.splice(b,1),!0},e.insertAfter=function(a){for(var b=this.items.length;b--;)this.items[b].insertAfter(a);return this},e.getBBox=function(){for(var a=[],d=[],e=[],f=[],g=this.items.length;g--;)if(!this.items[g].removed){var h=this.items[g].getBBox();a.push(h.x),d.push(h.y),e.push(h.x+h.width),f.push(h.y+h.height)}return a=c.apply(0,a),d=c.apply(0,d),e=b.apply(0,e),f=b.apply(0,f),{x:a,y:d,x2:e,y2:f,width:e-a,height:f-d,cx:a+(e-a)/2,cy:d+(f-d)/2}},e.clone=function(a){a=new d;for(var b=0,c=this.items.length;c>b;b++)a.push(this.items[b].clone());return a},e.toString=function(){return"Savage‘s set"},e.type="set",a.set=function(){var a=new d;return arguments.length&&a.push.apply(a,Array.prototype.slice.call(arguments,0)),a}}),Savage.plugin(function(a,b){function c(a){var b=a[0];switch(b.toLowerCase()){case"t":return[b,0,0];case"m":return[b,1,0,0,1,0,0];case"r":return 4==a.length?[b,0,a[2],a[3]]:[b,0];case"s":return 5==a.length?[b,1,1,a[3],a[4]]:3==a.length?[b,1,1]:[b,1]}}function d(b,d){d=l(d).replace(/\.{3}|\u2026/g,b),b=a.parseTransformString(b)||[],d=a.parseTransformString(d)||[];for(var e,f,g,j,k=Math.max(b.length,d.length),m=[],n=[],o=0;k>o;o++){if(g=b[o]||c(d[o]),j=d[o]||c(g),g[0]!=j[0]||"r"==g[0].toLowerCase()&&(g[2]!=j[2]||g[3]!=j[3])||"s"==g[0].toLowerCase()&&(g[3]!=j[3]||g[4]!=j[4]))return;for(m[o]=[],n[o]=[],e=0,f=Math.max(g.length,j.length);f>e;e++)e in g&&(m[o][e]=g[e]),e in j&&(n[o][e]=j[e])}return{from:i(m),to:i(n),f:h(m)}}function e(a){return a}function f(a){return function(b){return+b.toFixed(3)+a}}function g(b){return a.rgb(b[0],b[1],b[2])}function h(a){var b,c,d,e,f,g,h=0,i=[];for(b=0,c=a.length;c>b;b++){for(f="[",g=['"'+a[b][0]+'"'],d=1,e=a[b].length;e>d;d++)g[d]="val["+h++ +"]";f+=g+"]",i[b]=f}return Function("val","return Savage.path.toString.call(["+i+"])")}function i(a){for(var b=[],c=0,d=a.length;d>c;c++)for(var e=1,f=a[c].length;f>e;e++)b.push(a[c][e]);return b}var j={},k=/[a-z]+$/i,l=String;j.stroke=j.fill="colour",b.prototype.equal=function(b,c){var m,n,o=l(this.attr(b)||"");if(o==+o&&c==+c)return{from:+o,to:+c,f:e};if("colour"==j[b])return m=a.color(o),n=a.color(c),{from:[m.r,m.g,m.b,m.opacity],to:[n.r,n.g,n.b,n.opacity],f:g};if("transform"==b||"gradientTransform"==b||"patternTransform"==b)return d(o.local,c);if("d"==b||"path"==b)return m=a.path.toCubic(o,c),{from:i(m[0]),to:i(m[1]),f:h(m[0])};var p=o.match(k),q=c.match(k);return p&&p==q?{from:parseFloat(o),to:parseFloat(c),f:f(p)}:{from:this.asPX(b),to:this.asPX(b,c),f:e}}}),Savage.plugin(function(a,b,c,d){for(var e=b.prototype,f="hasOwnProperty",g=("createTouch"in d.doc),h=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","touchstart","touchmove","touchend","touchcancel"],i={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},j=function(a){var b="y"==a?"scrollTop":"scrollLeft";return d.doc.documentElement[b]||d.doc.body[b]},k=function(){this.returnValue=!1},l=function(){return this.originalEvent.preventDefault()},m=function(){this.cancelBubble=!0},n=function(){return this.originalEvent.stopPropagation()},o=function(){return d.doc.addEventListener?function(a,b,c,d){var e=g&&i[b]?i[b]:b,h=function(e){var h=j("y"),k=j("x"),m=e.clientX+k,o=e.clientY+h;if(g&&i[f](b))for(var p=0,q=e.targetTouches&&e.targetTouches.length;q>p;p++)if(e.targetTouches[p].target==a){var r=e;e=e.targetTouches[p],e.originalEvent=r,e.preventDefault=l,e.stopPropagation=n;break}return c.call(d,e,m,o)};return a.addEventListener(e,h,!1),function(){return a.removeEventListener(e,h,!1),!0}}:d.doc.attachEvent?function(a,b,c,e){var f=function(a){a=a||d.win.event;var b=j("y"),f=j("x"),g=a.clientX+f,h=a.clientY+b;return a.preventDefault=a.preventDefault||k,a.stopPropagation=a.stopPropagation||m,c.call(e,a,g,h)};a.attachEvent("on"+b,f);var g=function(){return a.detachEvent("on"+b,f),!0};return g}:void 0}(),p=[],q=function(a){for(var b,c=a.clientX,d=a.clientY,e=j("y"),f=j("x"),h=p.length;h--;){if(b=p[h],g){for(var i,k=a.touches.length;k--;)if(i=a.touches[k],i.identifier==b.el._drag.id){c=i.clientX,d=i.clientY,(a.originalEvent?a.originalEvent:a).preventDefault();break}}else a.preventDefault();var l=b.el.node;l.nextSibling,l.parentNode,l.style.display,c+=f,d+=e,eve("savage.drag.move."+b.el.id,b.move_scope||b.el,c-b.el._drag.x,d-b.el._drag.y,c,d,a)}},r=function(b){a.unmousemove(q).unmouseup(r);for(var c,d=p.length;d--;)c=p[d],c.el._drag={},eve("savage.drag.end."+c.el.id,c.end_scope||c.start_scope||c.move_scope||c.el,b);p=[]},s=h.length;s--;)!function(b){a[b]=e[b]=function(c,e){return a.is(c,"function")&&(this.events=this.events||[],this.events.push({name:b,f:c,unbind:o(this.shape||this.node||d.doc,b,c,e||this)})),this},a["un"+b]=e["un"+b]=function(a){for(var c=this.events||[],d=c.length;d--;)if(c[d].name==b&&c[d].f==a)return c[d].unbind(),c.splice(d,1),!c.length&&delete this.events,this;return this}}(h[s]);e.data=function(b,c){var d=eldata[this.id]=eldata[this.id]||{};if(1==arguments.length){if(a.is(b,"object")){for(var e in b)b[f](e)&&this.data(e,b[e]);return this}return eve("savage.data.get."+this.id,this,d[b],b),d[b]}return d[b]=c,eve("savage.data.set."+this.id,this,c,b),this},e.removeData=function(a){return null==a?eldata[this.id]={}:eldata[this.id]&&delete eldata[this.id][a],this},e.hover=function(a,b,c,d){return this.mouseover(a,c).mouseout(b,d||c)},e.unhover=function(a,b){return this.unmouseover(a).unmouseout(b)};var t=[];e.drag=function(b,c,d,e,f,g){function h(h){(h.originalEvent||h).preventDefault();var i=j("y"),k=j("x");this._drag.x=h.clientX+k,this._drag.y=h.clientY+i,this._drag.id=h.identifier,!p.length&&a.mousemove(q).mouseup(r),p.push({el:this,move_scope:e,start_scope:f,end_scope:g}),c&&eve.on("savage.drag.start."+this.id,c),b&&eve.on("savage.drag.move."+this.id,b),d&&eve.on("savage.drag.end."+this.id,d),eve("savage.drag.start."+this.id,f||e||this,h.clientX+k,h.clientY+i,h)}if(!arguments.length){var i;return this.drag(function(a,b){this.attr({transform:i+(i?"T":"t")+[a,b]})},function(){i=this.transform().local})}return this._drag={},t.push({el:this,start:h}),this.mousedown(h),this},e.onDragOver=function(a){a?eve.on("savage.drag.over."+this.id,a):eve.unbind("savage.drag.over."+this.id)},e.undrag=function(){for(var b=t.length;b--;)t[b].el==this&&(this.unmousedown(t[b].start),t.splice(b,1),eve.unbind("savage.drag.*."+this.id));!t.length&&a.unmousemove(q).unmouseup(r)}}); \ No newline at end of file diff --git a/savage.js b/savage.js index 3d5dd03..d1cdd3f 100644 --- a/savage.js +++ b/savage.js @@ -28,7 +28,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -// build: 2013-08-05 +// build: 2013-08-09 // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -907,13 +907,14 @@ Savage.version = "0.0.1"; function Savage(w, h) { if (w) { if (w.tagName) { - return new Element(w); + return wrap(w); } if (w instanceof Element) { return w; } if (h == null) { - return new Element(glob.doc.querySelector(w)); + w = glob.doc.querySelector(w); + return wrap(w); } } w = w == null ? "100%" : w; @@ -2140,7 +2141,7 @@ function unit2px(el, name, value) { = (Element) \*/ Savage.select = function (query) { - return new Element(glob.doc.querySelector(query)); + return wrap(glob.doc.querySelector(query)); }; /*\ * Savage.selectAll @@ -2155,7 +2156,7 @@ Savage.selectAll = function (query) { var nodelist = glob.doc.querySelectorAll(query), set = (Savage.set || Array)(); for (var i = 0; i < nodelist.length; i++) { - set.push(new Element(nodelist[i])); + set.push(wrap(nodelist[i])); } return set; }; @@ -2322,13 +2323,13 @@ function arrayFirstValue(arr) { this.removed = true; }; elproto.select = function (query) { - return new Element(this.node.querySelector(query)); + return wrap(this.node.querySelector(query)); }; elproto.selectAll = function (query) { var nodelist = this.node.querySelectorAll(query), set = (Savage.set || Array)(); for (var i = 0; i < nodelist.length; i++) { - set.push(new Element(nodelist[i])); + set.push(wrap(nodelist[i])); } return set; }; @@ -2359,7 +2360,7 @@ function arrayFirstValue(arr) { var clone = this.node.cloneNode(true); // TODO replace with this.insertAfter() this.node.parentNode.insertBefore(clone, this.node); - return new Element(clone); + return wrap(clone); }; elproto.pattern = function (x, y, width, height) { var p = make("pattern", this.paper.defs); @@ -2418,13 +2419,12 @@ function arrayFirstValue(arr) { }; } elproto.animate = function (attrs, ms, callback) { - var anims = [], eq; for (var key in attrs) if (attrs[has](key)) { if (this.equal) { - eq = this.equal(key, Str(attrs[key])); - anims.push(mina(eq.from, eq.to, ms, applyAttr(this, key, eq.f))); + var eq = this.equal(key, Str(attrs[key])); + return mina(eq.from, eq.to, ms, applyAttr(this, key, eq.f)); } else { - anims.push(mina(+this.attr(key), +attrs[key], ms, applyAttr(this, key))); + return mina(+this.attr(key), +attrs[key], ms, applyAttr(this, key)); } } }; @@ -2474,7 +2474,7 @@ Savage.fragment = function () { function make(name, parent) { var res = $(name); parent.appendChild(res); - var el = new Element(res); + var el = wrap(res); el.type = name; return el; } @@ -2516,9 +2516,15 @@ function Paper(w, h) { return res; } function wrap(dom) { + if (!dom) { + return dom; + } if (dom instanceof Element || dom instanceof Fragment) { return dom; } + if (dom.tagName == "svg") { + return new Paper(dom); + } return new Element(dom); } (function (proto) { @@ -3437,7 +3443,7 @@ Savage.plugin(function (Savage, Element, Paper, glob) { z = z > 1 ? 1 : z < 0 ? 0 : z; var z2 = z / 2, n = 12, - Tvalues = [-0.1252,0.1252,-0.3678,0.3678,-0.5873,0.5873,-0.7699,0.7699,-0.9041,0.9041,-0.9816,0.9816], + Tvalues = [-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816], Cvalues = [0.2491,0.2491,0.2335,0.2335,0.2032,0.2032,0.1601,0.1601,0.1069,0.1069,0.0472,0.0472], sum = 0; for (var i = 0; i < n; i++) { diff --git a/savage.path.js b/savage.path.js index 8fafa75..26b1306 100644 --- a/savage.path.js +++ b/savage.path.js @@ -207,7 +207,7 @@ Savage.plugin(function (Savage, Element, Paper, glob) { z = z > 1 ? 1 : z < 0 ? 0 : z; var z2 = z / 2, n = 12, - Tvalues = [-0.1252,0.1252,-0.3678,0.3678,-0.5873,0.5873,-0.7699,0.7699,-0.9041,0.9041,-0.9816,0.9816], + Tvalues = [-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816], Cvalues = [0.2491,0.2491,0.2335,0.2335,0.2032,0.2032,0.1601,0.1601,0.1069,0.1069,0.0472,0.0472], sum = 0; for (var i = 0; i < n; i++) { diff --git a/svg.js b/svg.js index e15f177..d213b7a 100644 --- a/svg.js +++ b/svg.js @@ -3,13 +3,14 @@ Savage.version = "0.0.1"; function Savage(w, h) { if (w) { if (w.tagName) { - return new Element(w); + return wrap(w); } if (w instanceof Element) { return w; } if (h == null) { - return new Element(glob.doc.querySelector(w)); + w = glob.doc.querySelector(w); + return wrap(w); } } w = w == null ? "100%" : w; @@ -1236,7 +1237,7 @@ function unit2px(el, name, value) { = (Element) \*/ Savage.select = function (query) { - return new Element(glob.doc.querySelector(query)); + return wrap(glob.doc.querySelector(query)); }; /*\ * Savage.selectAll @@ -1251,7 +1252,7 @@ Savage.selectAll = function (query) { var nodelist = glob.doc.querySelectorAll(query), set = (Savage.set || Array)(); for (var i = 0; i < nodelist.length; i++) { - set.push(new Element(nodelist[i])); + set.push(wrap(nodelist[i])); } return set; }; @@ -1418,13 +1419,13 @@ function arrayFirstValue(arr) { this.removed = true; }; elproto.select = function (query) { - return new Element(this.node.querySelector(query)); + return wrap(this.node.querySelector(query)); }; elproto.selectAll = function (query) { var nodelist = this.node.querySelectorAll(query), set = (Savage.set || Array)(); for (var i = 0; i < nodelist.length; i++) { - set.push(new Element(nodelist[i])); + set.push(wrap(nodelist[i])); } return set; }; @@ -1455,7 +1456,7 @@ function arrayFirstValue(arr) { var clone = this.node.cloneNode(true); // TODO replace with this.insertAfter() this.node.parentNode.insertBefore(clone, this.node); - return new Element(clone); + return wrap(clone); }; elproto.pattern = function (x, y, width, height) { var p = make("pattern", this.paper.defs); @@ -1514,13 +1515,12 @@ function arrayFirstValue(arr) { }; } elproto.animate = function (attrs, ms, callback) { - var anims = [], eq; for (var key in attrs) if (attrs[has](key)) { if (this.equal) { - eq = this.equal(key, Str(attrs[key])); - anims.push(mina(eq.from, eq.to, ms, applyAttr(this, key, eq.f))); + var eq = this.equal(key, Str(attrs[key])); + return mina(eq.from, eq.to, ms, applyAttr(this, key, eq.f)); } else { - anims.push(mina(+this.attr(key), +attrs[key], ms, applyAttr(this, key))); + return mina(+this.attr(key), +attrs[key], ms, applyAttr(this, key)); } } }; @@ -1570,7 +1570,7 @@ Savage.fragment = function () { function make(name, parent) { var res = $(name); parent.appendChild(res); - var el = new Element(res); + var el = wrap(res); el.type = name; return el; } @@ -1612,9 +1612,15 @@ function Paper(w, h) { return res; } function wrap(dom) { + if (!dom) { + return dom; + } if (dom instanceof Element || dom instanceof Fragment) { return dom; } + if (dom.tagName == "svg") { + return new Paper(dom); + } return new Element(dom); } (function (proto) { diff --git a/test/test.html b/test/test.html index f859633..9242a58 100644 --- a/test/test.html +++ b/test/test.html @@ -13,7 +13,7 @@ - + @@ -41,7 +41,7 @@ describe("Check for Paper Creation", function () { it("creates simple paper 20 × 10", function () { var s = Savage(20, 10); - var S = document.querySelector("svg"); + var S = s.node; expect(S).to.not.be(null); expect(S.getAttribute("width")).to.be("20"); expect(S.getAttribute("height")).to.be("10"); @@ -49,20 +49,36 @@ }); it("removal of paper", function () { var s = Savage(20, 10); - var S = document.querySelector("svg"); + var S = s.node; expect(S).to.not.be(null); s.remove(); - S = document.querySelector("svg"); - expect(S).to.be(null); + S = document.querySelectorAll("svg").length; + expect(S).to.be(1); }); it("creates simple paper 20% × 10em", function () { var s = Savage("20%", "10em"); - var S = document.querySelector("svg"); + var S = s.node; expect(S).to.not.be(null); expect(S.getAttribute("width")).to.be("20%"); expect(S.getAttribute("height")).to.be("10em"); s.remove(); }); + it("converts existing SVG element to paper", function () { + var S = document.getElementById("svgroot"); + var s = Savage(S); + expect(document.querySelector("#svgroot circle")).to.be(null); + var c = s.circle(10, 20, 5); + expect(document.querySelectorAll("#svgroot circle").length).to.be(1); + c.remove(); + }); + it("converts existing SVG element to paper (as query)", function () { + var S = document.getElementById("svgroot"); + var s = Savage("#svgroot"); + expect(document.querySelector("#svgroot circle")).to.be(null); + var c = s.circle(10, 20, 5); + expect(document.querySelectorAll("#svgroot circle").length).to.be(1); + c.remove(); + }); }); describe("Primitives creation", function () { var s; @@ -511,5 +527,6 @@ mocha.run(); }; + \ No newline at end of file diff --git a/elemental.js b/third-party/elemental.js similarity index 100% rename from elemental.js rename to third-party/elemental.js