UNPKG

fm-gsap-trial

Version:
11 lines (9 loc) 5.87 kB
/*! * PixiPlugin 3.12.5 * https://gsap.com * * @license Copyright 2024, GreenSock. All rights reserved. * Subject to the terms at https://gsap.com/standard-license or for Club GSAP members, the agreement issued with that membership. * @author: Jack Doyle, jack@greensock.com */ let t,r,e,i,o,s,l,n,a,u=()=>"undefined"!=typeof window,h=()=>t||u()&&(t=window.gsap)&&t.registerPlugin&&t,c=t=>"function"==typeof t,p=t=>console.warn(t),g=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],d=.212671,f=.71516,b=.072169,x=t=>c(i[t])?i[t]:i.filters[t],m=(t,r)=>{let e,i,o=[],s=0,l=0;for(e=0;e<4;e++){for(i=0;i<5;i++)l=4===i?t[s+4]:0,o[s+i]=t[s]*r[i]+t[s+1]*r[i+5]+t[s+2]*r[i+10]+t[s+3]*r[i+15]+l;s+=5}return o},P=(t,r)=>{let e=1-r,i=e*d,o=e*f,s=e*b;return m([i+r,o,s,0,0,i,o+r,s,0,0,i,o,s+r,0,0,0,0,0,1,0],t)},z=(t,e,i)=>{let o=r(e),s=o[0]/255,l=o[1]/255,n=o[2]/255,a=1-i;return m([a+i*s*d,i*s*f,i*s*b,0,0,i*l*d,a+i*l*f,i*l*b,0,0,i*n*d,i*n*f,a+i*n*b,0,0,0,0,0,1,0],t)},w=(t,r)=>{r*=Math.PI/180;let e=Math.cos(r),i=Math.sin(r);return m([d+e*(1-d)+i*-d,f+e*-f+i*-f,b+e*-b+i*(1-b),0,0,d+e*-d+.143*i,f+.28484*e+.14*i,b+e*-b+-.283*i,0,0,d+e*-d+-.787329*i,f+e*-f+i*f,b+e*(1-b)+i*b,0,0,0,0,0,1,0,0,0,0,0,1],t)},M=(t,r)=>m([r,0,0,0,.5*(1-r),0,r,0,0,.5*(1-r),0,0,r,0,.5*(1-r),0,0,0,1,0],t),A=(t,r)=>{let e,i=x(r),o=t.filters||[],s=o.length;for(i||p(r+" not found. PixiPlugin.registerPIXI(PIXI)");--s>-1;)if(o[s]instanceof i)return o[s];return e=new i,"BlurFilter"===r&&(e.blur=0),o.push(e),t.filters=o,e},I=(t,r,e,i)=>{r.add(e,t,e[t],i[t]),r._props.push(t)},F=(t,r)=>{let e=new(x("ColorMatrixFilter"));return e.matrix=r,e.brightness(t,!0),e.matrix},_={contrast:1,saturation:1,colorizeAmount:0,colorize:"rgb(255,255,255)",hue:0,brightness:1},y=(t,r,e)=>{let i,o,s,l=A(t,"ColorMatrixFilter"),n=t._gsColorMatrixFilter=t._gsColorMatrixFilter||(t=>{let r,e={};for(r in t)e[r]=t[r];return e})(_),a=r.combineCMF&&!("colorMatrixFilter"in r&&!r.colorMatrixFilter);s=l.matrix,r.resolution&&(l.resolution=r.resolution),r.matrix&&r.matrix.length===s.length?(o=r.matrix,1!==n.contrast&&I("contrast",e,n,_),n.hue&&I("hue",e,n,_),1!==n.brightness&&I("brightness",e,n,_),n.colorizeAmount&&(I("colorize",e,n,_),I("colorizeAmount",e,n,_)),1!==n.saturation&&I("saturation",e,n,_)):(o=g.slice(),null!=r.contrast?(o=M(o,+r.contrast),I("contrast",e,n,r)):1!==n.contrast&&(a?o=M(o,n.contrast):I("contrast",e,n,_)),null!=r.hue?(o=w(o,+r.hue),I("hue",e,n,r)):n.hue&&(a?o=w(o,n.hue):I("hue",e,n,_)),null!=r.brightness?(o=F(+r.brightness,o),I("brightness",e,n,r)):1!==n.brightness&&(a?o=F(n.brightness,o):I("brightness",e,n,_)),null!=r.colorize?(r.colorizeAmount="colorizeAmount"in r?+r.colorizeAmount:1,o=z(o,r.colorize,r.colorizeAmount),I("colorize",e,n,r),I("colorizeAmount",e,n,r)):n.colorizeAmount&&(a?o=z(o,n.colorize,n.colorizeAmount):(I("colorize",e,n,_),I("colorizeAmount",e,n,_))),null!=r.saturation?(o=P(o,+r.saturation),I("saturation",e,n,r)):1!==n.saturation&&(a?o=P(o,n.saturation):I("saturation",e,n,_))),i=o.length;for(;--i>-1;)o[i]!==s[i]&&e.add(s,i,s[i],o[i],"colorMatrixFilter");e._props.push("colorMatrixFilter")},C=(t,{t:r,p:e,color:i,set:o})=>{o(r,e,i[0]<<16|i[1]<<8|i[2])},X=(t,{g:r})=>{r&&(r.dirty++,r.clearDirty++)},v=(t,r)=>{r.t.visible=!!r.t.alpha},S=(t,e,i,l)=>{let n=t[e],a=r(c(n)?t[e.indexOf("set")||!c(t["get"+e.substr(3)])?e:"get"+e.substr(3)]():n),u=r(i);l._pt=new o(l._pt,t,e,0,0,C,{t:t,p:e,color:a,set:s(t,e)}),l.add(a,0,a[0],u[0]),l.add(a,1,a[1],u[1]),l.add(a,2,a[2],u[2])},O={tint:1,lineColor:1,fillColor:1},Y="position,scale,skew,pivot,anchor,tilePosition,tileScale".split(","),k={x:"position",y:"position",tileX:"tilePosition",tileY:"tilePosition"},B={colorMatrixFilter:1,saturation:1,contrast:1,hue:1,colorize:1,colorizeAmount:1,brightness:1,combineCMF:1},D=Math.PI/180,E=t=>"string"==typeof t,N=t=>E(t)&&"="===t.charAt(1)?t.substr(0,2)+parseFloat(t.substr(2))*D:t*D,R=(t,r)=>r.set(r.t,r.p,1===t?r.e:Math.round(1e5*(r.s+r.c*t))/1e5,r),V=(t,r,e,i,s,l)=>{let n,a,u=360*(l?D:1),h=E(s),c=h&&"="===s.charAt(1)?+(s.charAt(0)+"1"):0,p=parseFloat(c?s.substr(2):s)*(l?D:1),g=c?p*c:p-i,d=i+g;return h&&(n=s.split("_")[1],"short"===n&&(g%=u,g!==g%(u/2)&&(g+=g<0?u:-u)),"cw"===n&&g<0?g=(g+1e10*u)%u-~~(g/u)*u:"ccw"===n&&g>0&&(g=(g-1e10*u)%u-~~(g/u)*u)),t._pt=a=new o(t._pt,r,e,i,g,R),a.e=d,a},G=()=>{e||(t=h(),i=e=i||u()&&window.PIXI,l=i&&i.VERSION&&"4"===i.VERSION.charAt(0),r=r=>t.utils.splitColor("0x"===(r+"").substr(0,2)?"#"+r.substr(2):r))};for(n=0;n<Y.length;n++)a=Y[n],k[a+"X"]=a,k[a+"Y"]=a;const L={version:"3.12.5",name:"pixi",register(r,e,i){t=r,o=i,s=e.getSetter,G()},headless:!0,registerPIXI(t){i=t},init(t,r,e,s,n){if(i||G(),!i)return p("PIXI was not found. PixiPlugin.registerPIXI(PIXI);"),!1;let a,u,h,c,g,d,f,b,x;for(d in r){if(a=k[d],h=r[d],a)u=~d.charAt(d.length-1).toLowerCase().indexOf("x")?"x":"y",this.add(t[a],u,t[a][u],"skew"===a?N(h):h,0,0,0,0,0,1);else if("scale"===d||"anchor"===d||"pivot"===d||"tileScale"===d)this.add(t[d],"x",t[d].x,h),this.add(t[d],"y",t[d].y,h);else if("rotation"===d||"angle"===d)V(this,t,d,t[d],h,"rotation"===d);else if(B[d])c||(y(t,r.colorMatrixFilter||r,this),c=!0);else if("blur"===d||"blurX"===d||"blurY"===d||"blurPadding"===d){if(g=A(t,"BlurFilter"),this.add(g,d,g[d],h),0!==r.blurPadding)for(f=r.blurPadding||2*Math.max(g[d],h),b=t.filters.length;--b>-1;)t.filters[b].padding=Math.max(t.filters[b].padding,f)}else if(O[d])if(("lineColor"===d||"fillColor"===d)&&t instanceof i.Graphics)for(x=(t.geometry||t).graphicsData,this._pt=new o(this._pt,t,d,0,0,X,{g:t.geometry||t}),b=x.length;--b>-1;)S(l?x[b]:x[b][d.substr(0,4)+"Style"],l?d:"color",h,this);else S(t,d,h,this);else"autoAlpha"===d?(this._pt=new o(this._pt,t,"visible",0,0,v),this.add(t,"alpha",t.alpha,h),this._props.push("alpha","visible")):"resolution"!==d&&this.add(t,d,"get",h);this._props.push(d)}}};h()&&t.registerPlugin(L);export default L;export{L as PixiPlugin};