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

13 lines
16 KiB
JavaScript
Raw Normal View History

2019-03-21 09:57:27 +01:00
/*!
* VERSION: 0.9.0
* DATE: 2019-02-07
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* MorphSVGPlugin 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";var a,b=Math.PI,c=b/180,d=/[achlmqstvz]|(-?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/gi,e=/(?:(-|-=|\+=)?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/gi,f=/(^[#\.][a-z]|[a-y][a-z])/gi,g=/[achlmqstvz]/gi,h=/[\+\-]?\d*\.?\d+e[\+\-]?\d+/gi,i=Math.atan2,j=Math.cos,k=Math.sin,l=Math.sqrt,m=2*b,n=.3*b,o=.7*b,p=_gsScope._gsDefine.globals.TweenLite,q=function(a){_gsScope.console&&console.log(a)},r=function(a,b,d,e,f,g,h,i,n){if(a!==i||b!==n){d=Math.abs(d),e=Math.abs(e);var o=f%360*c,p=j(o),q=k(o),r=(a-i)/2,s=(b-n)/2,t=p*r+q*s,u=-q*r+p*s,v=t*t,w=u*u,x=v/(d*d)+w/(e*e);x>1&&(d=l(x)*d,e=l(x)*e);var y=d*d,z=e*e,A=(y*z-y*w-z*v)/(y*w+z*v);0>A&&(A=0);var B=(g===h?-1:1)*l(A),C=B*(d*u/e),D=B*-(e*t/d),E=(a+i)/2,F=(b+n)/2,G=E+(p*C-q*D),H=F+(q*C+p*D),I=(t-C)/d,J=(u-D)/e,K=(-t-C)/d,L=(-u-D)/e,M=I*I+J*J,N=(0>J?-1:1)*Math.acos(I/l(M)),O=(0>I*L-J*K?-1:1)*Math.acos((I*K+J*L)/l(M*(K*K+L*L)));!h&&O>0?O-=m:h&&0>O&&(O+=m),N%=m,O%=m;var P,Q=Math.ceil(Math.abs(O)/(m/4)),R=[],S=O/Q,T=4/3*k(S/2)/(1+j(S/2)),U=p*d,V=q*d,W=q*-e,X=p*e;for(P=0;Q>P;P++)f=N+P*S,t=j(f),u=k(f),I=j(f+=S),J=k(f),R.push(t-T*u,u+T*t,I+T*J,J-T*I,I,J);for(P=0;P<R.length;P+=2)t=R[P],u=R[P+1],R[P]=t*U+u*W+G,R[P+1]=t*V+u*X+H;return R[P-2]=i,R[P-1]=n,R}},s=function(a){var b,c,e,f,g,i,j,k,l,m,n,o,p,s=(a+"").replace(h,function(a){var b=+a;return 1e-4>b&&b>-1e-4?0:b}).match(d)||[],t=[],u=0,v=0,w=2/3,x=s.length,y=0,z="ERROR: malformed path: "+a,A=function(a,b,c,d){m=(c-a)/3,n=(d-b)/3,j.push(a+m,b+n,c-m,d-n,c,d)};if(!a||!isNaN(s[0])||isNaN(s[1]))return q(z),t;for(b=0;x>b;b++)if(p=g,isNaN(s[b])?(g=s[b].toUpperCase(),i=g!==s[b]):b--,e=+s[b+1],f=+s[b+2],i&&(e+=u,f+=v),b||(k=e,l=f),"M"===g)j&&(j.length<8?t.length-=1:y+=j.length),u=k=e,v=l=f,j=[e,f],t.push(j),b+=2,g="L";else if("C"===g)j||(j=[0,0]),i||(u=v=0),j.push(e,f,u+1*s[b+3],v+1*s[b+4],u+=1*s[b+5],v+=1*s[b+6]),b+=6;else if("S"===g)m=u,n=v,("C"===p||"S"===p)&&(m+=u-j[j.length-4],n+=v-j[j.length-3]),i||(u=v=0),j.push(m,n,e,f,u+=1*s[b+3],v+=1*s[b+4]),b+=4;else if("Q"===g)m=u+(e-u)*w,n=v+(f-v)*w,i||(u=v=0),u+=1*s[b+3],v+=1*s[b+4],j.push(m,n,u+(e-u)*w,v+(f-v)*w,u,v),b+=4;else if("T"===g)m=u-j[j.length-4],n=v-j[j.length-3],j.push(u+m,v+n,e+(u+1.5*m-e)*w,f+(v+1.5*n-f)*w,u=e,v=f),b+=2;else if("H"===g)A(u,v,u=e,v),b+=1;else if("V"===g)A(u,v,u,v=e+(i?v-u:0)),b+=1;else if("L"===g||"Z"===g)"Z"===g&&(e=k,f=l,j.closed=!0),("L"===g||Math.abs(u-e)>.5||Math.abs(v-f)>.5)&&(A(u,v,e,f),"L"===g&&(b+=2)),u=e,v=f;else if("A"===g){if(o=r(u,v,+s[b+1],+s[b+2],+s[b+3],+s[b+4],+s[b+5],(i?u:0)+1*s[b+6],(i?v:0)+1*s[b+7]))for(c=0;c<o.length;c++)j.push(o[c]);u=j[j.length-2],v=j[j.length-1],b+=7}else q(z);return b=j.length,j[0]===j[b-2]&&j[1]===j[b-1]&&(j.closed=!0),t.totalPoints=y+b,t},t=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q=0,r=.999999,s=a.length,t=b/((s-2)/6);for(o=2;s>o;o+=6)for(q+=t;q>r;)c=a[o-2],d=a[o-1],e=a[o],f=a[o+1],g=a[o+2],h=a[o+3],i=a[o+4],j=a[o+5],p=1/((Math.floor(q)||1)+1),k=c+(e-c)*p,m=e+(g-e)*p,k+=(m-k)*p,m+=(g+(i-g)*p-m)*p,l=d+(f-d)*p,n=f+(h-f)*p,l+=(n-l)*p,n+=(h+(j-h)*p-n)*p,a.splice(o,4,c+(e-c)*p,d+(f-d)*p,k,l,k+(m-k)*p,l+(n-l)*p,m,n,g+(i-g)*p,h+(j-h)*p),o+=6,s+=6,q--;return a},u=function(a,b){var c,d,e,f="",g=" ",h=a.length,i=Math.pow(10,b||2);for(d=0;d<a.length;d++){for(e=a[d],h=e.length,f+="M"+(e[0]*i|0)/i+g+(e[1]*i|0)/i+" C",c=2;h>c;c++)f+=(e[c]*i|0)/i+g;e.closed&&(f+="z")}return f},v=function(a){for(var b=[],c=a.length-1,d=0;--c>-1;)b[d++]=a[c],b[d++]=a[c+1],c--;for(c=0;d>c;c++)a[c]=b[c];a.reversed=!a.reversed},w=function(a){var b,c=a.length,d=0,e=0;for(b=0;c>b;b++)d+=a[b++],e+=a[b];return[d/(c/2),e/(c/2)]},x=function(a){var b,c,d,e=a.length,f=a[0],g=f,h=a[1],i=h;for(d=6;e>d;d+=6)b=a[d],c=a[d+1],b>f?f=b:g>b&&(g=b),c>h?h=c:i>c&&(i=c);return a.centerX=(f+g)/2,a.centerY=(h+i)/2,a.size=(f-g)*(h-i)},y=function(a,b){b=b||3;for(var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s=a.length,t=a[0][0],u=t,v=a[0][1],w=v,x=1/b;--s>-1;)for(g=a[s],c=g.length,f=6;c>f;f+=6)for(k=g[f],l=g[f+1],m=g[f+2]-k,p=g[f+3]-l,n=g[f+4