/** * @license A class to parse color values * @author Stoyan Stefanov * @link http://www.phpied.com/rgb-color-parser-in-javascript/ * Use it if you like it * */ /** * @license canvg.js - Javascript SVG parser and renderer on Canvas * MIT Licensed * Gabe Lerner (gabelerner@gmail.com) * http://code.google.com/p/canvg/ * * Requires: rgbcolor.js - http://www.phpied.com/rgb-color-parser-in-javascript/ * */ /** * @license Highcharts JS v2.3.3 (2012-10-04) * CanVGRenderer Extension module * * (c) 2011-2012 Torstein Hønsi, Erik Olsson * * License: www.highcharts.com/license */ function RGBColor(t){this.ok=!1,"#"==t.charAt(0)&&(t=t.substr(1,6)),t=t.replace(/ /g,""),t=t.toLowerCase();var e={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};for(var i in e)t==i&&(t=e[i]);for(var n=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(t){return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}}],s=0;s255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toHex=function(){var t=this.r.toString(16),e=this.g.toString(16),i=this.b.toString(16);return 1==t.length&&(t="0"+t),1==e.length&&(e="0"+e),1==i.length&&(i="0"+i),"#"+t+e+i},this.getHelpXML=function(){for(var t=new Array,i=0;i "+h.toRGB()+" -> "+h.toHex());l.appendChild(u),l.appendChild(f),o.appendChild(l)}catch(c){}return o}}window.console||(window.console={},window.console.log=function(){},window.console.dir=function(){}),Array.prototype.indexOf||(Array.prototype.indexOf=function(t){for(var e=0;e]*>/,"");var i=new ActiveXObject("Microsoft.XMLDOM");return i.async="false",i.loadXML(t),i},t.Property=function(e,i){this.name=e,this.value=i,this.hasValue=function(){return null!=this.value&&""!==this.value},this.numValue=function(){if(!this.hasValue())return 0;var t=parseFloat(this.value);return(this.value+"").match(/%$/)&&(t/=100),t},this.valueOrDefault=function(t){return this.hasValue()?this.value:t},this.numValueOrDefault=function(t){return this.hasValue()?this.numValue():t};var n=this;this.Color={addOpacity:function(e){var i=n.value;if(null!=e&&""!=e){var s=new RGBColor(n.value);s.ok&&(i="rgba("+s.r+", "+s.g+", "+s.b+", "+e+")")}return new t.Property(n.name,i)}},this.Definition={getDefinition:function(){var e=n.value.replace(/^(url\()?#([^\)]+)\)?$/,"$2");return t.Definitions[e]},isUrl:function(){return 0==n.value.indexOf("url(")},getFillStyle:function(e){var i=this.getDefinition();return null!=i&&i.createGradient?i.createGradient(t.ctx,e):null!=i&&i.createPattern?i.createPattern(t.ctx,e):null}},this.Length={DPI:function(){return 96},EM:function(e){var i=12,n=new t.Property("fontSize",t.Font.Parse(t.ctx.font).fontSize);return n.hasValue()&&(i=n.Length.toPixels(e)),i},toPixels:function(e){if(!n.hasValue())return 0;var i=n.value+"";return i.match(/em$/)?n.numValue()*this.EM(e):i.match(/ex$/)?n.numValue()*this.EM(e)/2:i.match(/px$/)?n.numValue():i.match(/pt$/)?1.25*n.numValue():i.match(/pc$/)?15*n.numValue():i.match(/cm$/)?n.numValue()*this.DPI(e)/2.54:i.match(/mm$/)?n.numValue()*this.DPI(e)/25.4:i.match(/in$/)?n.numValue()*this.DPI(e):i.match(/%$/)?n.numValue()*t.ViewPort.ComputeSize(e):n.numValue()}},this.Time={toMilliseconds:function(){if(!n.hasValue())return 0;var t=n.value+"";return t.match(/s$/)?1e3*n.numValue():t.match(/ms$/)?n.numValue():n.numValue()}},this.Angle={toRadians:function(){if(!n.hasValue())return 0;var t=n.value+"";return t.match(/deg$/)?n.numValue()*(Math.PI/180):t.match(/grad$/)?n.numValue()*(Math.PI/200):t.match(/rad$/)?n.numValue():n.numValue()*(Math.PI/180)}}},t.Font=new function(){this.Styles=["normal","italic","oblique","inherit"],this.Variants=["normal","small-caps","inherit"],this.Weights=["normal","bold","bolder","lighter","100","200","300","400","500","600","700","800","900","inherit"],this.CreateFont=function(e,i,n,s,a,r){var o=null!=r?this.Parse(r):this.CreateFont("","","","","",t.ctx.font);return{fontFamily:a||o.fontFamily,fontSize:s||o.fontSize,fontStyle:e||o.fontStyle,fontWeight:n||o.fontWeight,fontVariant:i||o.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var e=this;this.Parse=function(i){for(var n={},s=t.trim(t.compressSpaces(i||"")).split(" "),a={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1},r="",o=0;othis.x2&&(this.x2=t)),null!=e&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))},this.addX=function(t){this.addPoint(t,null)},this.addY=function(t){this.addPoint(null,t)},this.addBoundingBox=function(t){this.addPoint(t.x1,t.y1),this.addPoint(t.x2,t.y2)},this.addQuadraticCurve=function(t,e,i,n,s,a){var r=t+2/3*(i-t),o=e+2/3*(n-e),l=r+1/3*(s-t),h=o+1/3*(a-e);this.addBezierCurve(t,e,r,l,o,h,s,a)},this.addBezierCurve=function(t,e,n,s,a,r,o,l){var h=[t,e],u=[n,s],f=[a,r],c=[o,l];for(this.addPoint(h[0],h[1]),this.addPoint(c[0],c[1]),i=0;1>=i;i++){var d=function(t){return Math.pow(1-t,3)*h[i]+3*Math.pow(1-t,2)*t*u[i]+3*(1-t)*Math.pow(t,2)*f[i]+Math.pow(t,3)*c[i]},m=6*h[i]-12*u[i]+6*f[i],p=-3*h[i]+9*u[i]-9*f[i]+3*c[i],g=3*u[i]-3*h[i];if(0!=p){var y=Math.pow(m,2)-4*g*p;if(!(0>y)){var v=(-m+Math.sqrt(y))/(2*p);v>0&&1>v&&(0==i&&this.addX(d(v)),1==i&&this.addY(d(v)));var b=(-m-Math.sqrt(y))/(2*p);b>0&&1>b&&(0==i&&this.addX(d(b)),1==i&&this.addY(d(b)))}}else{if(0==m)continue;var x=-g/m;x>0&&1>x&&(0==i&&this.addX(d(x)),1==i&&this.addY(d(x)))}}},this.isPointInBox=function(t,e){return this.x1<=t&&t<=this.x2&&this.y1<=e&&e<=this.y2},this.addPoint(t,e),this.addPoint(n,s)},t.Transform=function(e){var i=this;this.Type={},this.Type.translate=function(e){this.p=t.CreatePoint(e),this.apply=function(t){t.translate(this.p.x||0,this.p.y||0)},this.applyToPoint=function(t){t.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0])}},this.Type.rotate=function(e){var i=t.ToNumberArray(e);this.angle=new t.Property("angle",i[0]),this.cx=i[1]||0,this.cy=i[2]||0,this.apply=function(t){t.translate(this.cx,this.cy),t.rotate(this.angle.Angle.toRadians()),t.translate(-this.cx,-this.cy)},this.applyToPoint=function(t){var e=this.angle.Angle.toRadians();t.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0]),t.applyTransform([Math.cos(e),Math.sin(e),-Math.sin(e),Math.cos(e),0,0]),t.applyTransform([1,0,0,1,-this.p.x||0,-this.p.y||0])}},this.Type.scale=function(e){this.p=t.CreatePoint(e),this.apply=function(t){t.scale(this.p.x||1,this.p.y||this.p.x||1)},this.applyToPoint=function(t){t.applyTransform([this.p.x||0,0,0,this.p.y||0,0,0])}},this.Type.matrix=function(e){this.m=t.ToNumberArray(e),this.apply=function(t){t.transform(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5])},this.applyToPoint=function(t){t.applyTransform(this.m)}},this.Type.SkewBase=function(e){this.base=i.Type.matrix,this.base(e),this.angle=new t.Property("angle",e)},this.Type.SkewBase.prototype=new this.Type.matrix,this.Type.skewX=function(t){this.base=i.Type.SkewBase,this.base(t),this.m=[1,0,Math.tan(this.angle.Angle.toRadians()),1,0,0]},this.Type.skewX.prototype=new this.Type.SkewBase,this.Type.skewY=function(t){this.base=i.Type.SkewBase,this.base(t),this.m=[1,Math.tan(this.angle.Angle.toRadians()),0,1,0,0]},this.Type.skewY.prototype=new this.Type.SkewBase,this.transforms=[],this.apply=function(t){for(var e=0;e=this.tokens.length-1},this.isCommandOrEnd=function(){return this.isEnd()?!0:null!=this.tokens[this.i+1].match(/^[A-Za-z]$/)},this.isRelativeCommand=function(){return this.command==this.command.toLowerCase()},this.getToken=function(){return this.i=this.i+1,this.tokens[this.i]},this.getScalar=function(){return parseFloat(this.getToken())},this.nextCommand=function(){this.previousCommand=this.command,this.command=this.getToken()},this.getPoint=function(){var e=new t.Point(this.getScalar(),this.getScalar());return this.makeAbsolute(e)},this.getAsControlPoint=function(){var t=this.getPoint();return this.control=t,t},this.getAsCurrentPoint=function(){var t=this.getPoint();return this.current=t,t},this.getReflectedControlPoint=function(){if("c"!=this.previousCommand.toLowerCase()&&"s"!=this.previousCommand.toLowerCase())return this.current;var e=new t.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y);return e},this.makeAbsolute=function(t){return this.isRelativeCommand()&&(t.x=this.current.x+t.x,t.y=this.current.y+t.y),t},this.addMarker=function(t,e,i){null!=i&&this.angles.length>0&&null==this.angles[this.angles.length-1]&&(this.angles[this.angles.length-1]=this.points[this.points.length-1].angleTo(i)),this.addMarkerAngle(t,null==e?null:e.angleTo(t))},this.addMarkerAngle=function(t,e){this.points.push(t),this.angles.push(e)},this.getMarkerPoints=function(){return this.points},this.getMarkerAngles=function(){for(var t=0;t1&&(f*=Math.sqrt(y),c*=Math.sqrt(y));var v=(m==p?-1:1)*Math.sqrt((Math.pow(f,2)*Math.pow(c,2)-Math.pow(f,2)*Math.pow(g.y,2)-Math.pow(c,2)*Math.pow(g.x,2))/(Math.pow(f,2)*Math.pow(g.y,2)+Math.pow(c,2)*Math.pow(g.x,2)));isNaN(v)&&(v=0);var b=new t.Point(v*f*g.y/c,v*-c*g.x/f),x=new t.Point((o.x+u.x)/2+Math.cos(d)*b.x-Math.sin(d)*b.y,(o.y+u.y)/2+Math.sin(d)*b.x+Math.cos(d)*b.y),w=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))},E=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(w(t)*w(e))},P=function(t,e){return(t[0]*e[1]=1&&(k=0),0==p&&k>0&&(k-=2*Math.PI),1==p&&0>k&&(k+=2*Math.PI);var V=new t.Point(x.x-f*Math.cos((C+k)/2),x.y-c*Math.sin((C+k)/2));if(i.addMarkerAngle(V,(C+k)/2+(0==p?1:-1)*Math.PI/2),i.addMarkerAngle(u,k+(0==p?1:-1)*Math.PI/2),n.addPoint(u.x,u.y),null!=e){var E=f>c?f:c,M=f>c?1:f/c,S=f>c?c/f:1;e.translate(x.x,x.y),e.rotate(d),e.scale(M,S),e.arc(0,0,E,C,C+k,1-p),e.scale(1/M,1/S),e.rotate(-d),e.translate(-x.x,-x.y)}}break;case"Z":null!=e&&e.closePath(),i.current=i.start}return n},this.getMarkers=function(){for(var t=this.PathParser.getMarkerPoints(),e=this.PathParser.getMarkerAngles(),i=[],n=0;nthis.maxDuration){if("indefinite"!=this.attribute("repeatCount").value)return"remove"!=this.attribute("fill").valueOrDefault("remove")||this.removed?!1:(this.removed=!0,this.getProperty().value=this.initialValue,!0);this.duration=0}this.duration=this.duration+t;var e=!1;if(this.begin0&&" "!=e[i-1]&&i0&&" "!=e[i-1]&&(i==e.length-1||" "==e[i+1])&&(a="initial"),"undefined"!=typeof t.glyphs[n]&&(s=t.glyphs[n][a],null==s&&"glyph"==t.glyphs[n].type&&(s=t.glyphs[n]))}else s=t.glyphs[n];return null==s&&(s=t.missingGlyph),s},this.renderChildren=function(e){var i=this.parent.style("font-family").Definition.getDefinition();if(null==i)""!=e.strokeStyle&&e.strokeText(t.compressSpaces(this.getText()),this.x,this.y),""!=e.fillStyle&&e.fillText(t.compressSpaces(this.getText()),this.x,this.y);else{var n=this.parent.style("font-size").numValueOrDefault(t.Font.Parse(t.ctx.font).fontSize),s=this.parent.style("font-style").valueOrDefault(t.Font.Parse(t.ctx.font).fontStyle),a=this.getText();i.isRTL&&(a=a.split("").reverse().join(""));for(var r=t.ToNumberArray(this.parent.attribute("dx").value),o=0;o0?e.childNodes[0].nodeValue:e.text,this.getText=function(){return this.text}},t.Element.tspan.prototype=new t.Element.TextElementBase,t.Element.tref=function(e){this.base=t.Element.TextElementBase,this.base(e),this.getText=function(){var t=this.attribute("xlink:href").Definition.getDefinition();return null!=t?t.children[0].getText():void 0}},t.Element.tref.prototype=new t.Element.TextElementBase,t.Element.a=function(e){this.base=t.Element.TextElementBase,this.base(e),this.hasText=!0;for(var i=0;i1?e.childNodes[1].nodeValue:"");i=i.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,""),i=t.compressSpaces(i);for(var n=i.split("}"),s=0;s0)for(var v=g[y].indexOf("url"),b=g[y].indexOf(")",v),x=g[y].substr(v+5,b-v-6),w=t.parseXml(t.ajax(x)),E=w.getElementsByTagName("font"),P=0;Pi;i++)mask[i]=Math.exp(-.5*(i/t)*(i/t));return mask}function n(t){for(var e=0,i=1;io;o++)for(var l=0;n>l;l++)for(var h=a(t,l,o,n,s,3)/255,u=0;4>u;u++){for(var f=i[0]*(0==h?255:a(t,l,o,n,s,u))*(0==h||3==u?1:h),c=1;c