iwmlib/lib/3rdparty/greensock/src/minified/plugins/DrawSVGPlugin.min.js

13 lines
4.9 KiB
JavaScript

/*!
* VERSION: 0.2.1
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* DrawSVGPlugin is a Club GreenSock membership benefit; You must have a valid membership to use
* this code without violating the terms of use. Visit http://greensock.com/club/ to sign up or get more details.
* This work is subject to the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";function a(a,b,c,d,e,f){return c=(parseFloat(c||0)-parseFloat(a||0))*e,d=(parseFloat(d||0)-parseFloat(b||0))*f,Math.sqrt(c*c+d*d)}function b(a){return"string"!=typeof a&&a.nodeType||(a=_gsScope.TweenLite.selector(a),a.length&&(a=a[0])),a}function c(a,b,c){var d,e,f=a.indexOf(" ");return-1===f?(d=void 0!==c?c+"":a,e=a):(d=a.substr(0,f),e=a.substr(f+1)),d=-1!==d.indexOf("%")?parseFloat(d)/100*b:parseFloat(d),e=-1!==e.indexOf("%")?parseFloat(e)/100*b:parseFloat(e),d>e?[e,d]:[d,e]}function d(c){if(!c)return 0;c=b(c);var d,e,f,g,h,i,k,m=c.tagName.toLowerCase(),n=1,o=1;"non-scaling-stroke"===c.getAttribute("vector-effect")&&(o=c.getScreenCTM(),n=Math.sqrt(o.a*o.a+o.b*o.b),o=Math.sqrt(o.d*o.d+o.c*o.c));try{e=c.getBBox()}catch(p){console.log("Error: Some browsers like Firefox won't report measurements of invisible elements (like display:none or masks inside defs).")}if(e&&(e.width||e.height)||!l[m]||(e={width:parseFloat(c.getAttribute(l[m][0])),height:parseFloat(c.getAttribute(l[m][1]))},"rect"!==m&&"line"!==m&&(e.width*=2,e.height*=2),"line"===m&&(e.x=parseFloat(c.getAttribute("x1")),e.y=parseFloat(c.getAttribute("y1")),e.width=Math.abs(e.width-e.x),e.height=Math.abs(e.height-e.y))),"path"===m)g=c.style.strokeDasharray,c.style.strokeDasharray="none",d=c.getTotalLength()||0,n!==o&&console.log("Warning: <path> length cannot be measured accurately when vector-effect is non-scaling-stroke and the element isn't proportionally scaled."),d*=(n+o)/2,c.style.strokeDasharray=g;else if("rect"===m)d=2*e.width*n+2*e.height*o;else if("line"===m)d=a(e.x,e.y,e.x+e.width,e.y+e.height,n,o);else if("polyline"===m||"polygon"===m)for(f=c.getAttribute("points").match(j)||[],"polygon"===m&&f.push(f[0],f[1]),d=0,h=2;h<f.length;h+=2)d+=a(f[h-2],f[h-1],f[h],f[h+1],n,o)||0;else("circle"===m||"ellipse"===m)&&(i=e.width/2*n,k=e.height/2*o,d=Math.PI*(3*(i+k)-Math.sqrt((3*i+k)*(i+3*k))));return d||0}function e(a,c){if(!a)return[0,0];a=b(a),c=c||d(a)+1;var e=i(a),f=e.strokeDasharray||"",g=parseFloat(e.strokeDashoffset),h=f.indexOf(",");return 0>h&&(h=f.indexOf(" ")),f=0>h?c:parseFloat(f.substr(0,h))||1e-5,f>c&&(f=c),[Math.max(0,-g),Math.max(0,f-g)]}var f,g=_gsScope.document,h="undefined"!=typeof window?window:g.defaultView||{getComputedStyle:function(){}},i=function(a){return h.getComputedStyle(a)},j=/(?:(-|-=|\+=)?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/gi,k=-1!==((_gsScope.navigator||{}).userAgent||"").indexOf("Edge"),l={rect:["width","height"],circle:["r","r"],ellipse:["rx","ry"],line:["x2","y2"]};f=_gsScope._gsDefine.plugin({propName:"drawSVG",API:2,version:"0.2.1",global:!0,overwriteProps:["drawSVG"],init:function(a,b,f,g){if(!a.getBBox)return!1;var h,j,l,m,n=d(a)+1;return this._style=a.style,this._target=a,"function"==typeof b&&(b=b(g,a)),b===!0||"true"===b?b="0 100%":b?-1===(b+"").indexOf(" ")&&(b="0 "+b):b="0 0",h=e(a,n),j=c(b,n,h[0]),this._length=n+10,0===h[0]&&0===j[0]?(l=Math.max(1e-5,j[1]-n),this._dash=n+l,this._offset=n-h[1]+l,this._offsetPT=this._addTween(this,"_offset",this._offset,n-j[1]+l,"drawSVG")):(this._dash=h[1]-h[0]||1e-6,this._offset=-h[0],this._dashPT=this._addTween(this,"_dash",this._dash,j[1]-j[0]||1e-5,"drawSVG"),this._offsetPT=this._addTween(this,"_offset",this._offset,-j[0],"drawSVG")),k&&(m=i(a),m.strokeLinecap!==m.strokeLinejoin&&(j=parseFloat(m.strokeMiterlimit),this._addTween(a.style,"strokeMiterlimit",j,j+1e-4,"strokeMiterlimit"))),this._live="non-scaling-stroke"===a.getAttribute("vector-effect")||-1!==(b+"").indexOf("live"),!0},set:function(a){if(this._firstPT){if(this._live){var b,c=d(this._target)+11;c!==this._length&&(b=c/this._length,this._length=c,this._offsetPT.s*=b,this._offsetPT.c*=b,this._dashPT?(this._dashPT.s*=b,this._dashPT.c*=b):this._dash*=b)}this._super.setRatio.call(this,a),this._style.strokeDashoffset=this._offset,1===a||0===a?this._style.strokeDasharray=this._offset<.001&&this._length-this._dash<=10?"none":this._offset===this._dash?"0px, 999999px":this._dash+"px,"+this._length+"px":this._style.strokeDasharray=this._dash+"px,"+this._length+"px"}}}),f.getLength=d,f.getPosition=e}),_gsScope._gsDefine&&_gsScope._gsQueue.pop()(),function(a){"use strict";var b=function(){return(_gsScope.GreenSockGlobals||_gsScope)[a]};"undefined"!=typeof module&&module.exports?(require("../TweenLite.min.js"),module.exports=b()):"function"==typeof define&&define.amd&&define(["TweenLite"],b)}("DrawSVGPlugin");