@litecanvas/utils 0.34.0 → 0.35.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/all.min.js CHANGED
@@ -1,3 +1,3 @@
1
- (()=>{var Tt=Object.defineProperty;var kt=(e,t)=>{for(var s in t)Tt(e,s,{get:t[s],enumerable:!0})};globalThis.utils=globalThis.utils||{};globalThis.utils.global=(e=!0)=>{for(let t in globalThis.utils)t!=="global"&&(e||globalThis[t]===void 0)&&(globalThis[t]=globalThis.utils[t])};var X={};kt(X,{ANCHOR_BOT_LEFT:()=>Jt,ANCHOR_BOT_RIGHT:()=>te,ANCHOR_CENTER:()=>Kt,ANCHOR_TOP_LEFT:()=>J,ANCHOR_TOP_RIGHT:()=>Qt,Actor:()=>R,BACK_IN:()=>ie,BACK_IN_OUT:()=>ne,BACK_OUT:()=>oe,BOUNCE_IN:()=>ht,BOUNCE_IN_OUT:()=>me,BOUNCE_OUT:()=>z,Camera:()=>y,DOWN:()=>Zt,EASE_IN:()=>se,EASE_IN_OUT:()=>ae,EASE_OUT:()=>re,ELASTIC_IN:()=>ue,ELASTIC_IN_OUT:()=>he,ELASTIC_OUT:()=>le,Grid:()=>k,LEFT:()=>Gt,LINEAR:()=>lt,Noise:()=>D,ONE:()=>jt,RIGHT:()=>$t,TypedGrid:()=>C,UP:()=>Wt,Vector:()=>w,ZERO:()=>Q,advance:()=>st,choose:()=>yt,colcirc:()=>q,colrect:()=>U,diff:()=>tt,dist:()=>at,flipImage:()=>pt,fract:()=>et,head:()=>wt,intersection:()=>T,last:()=>Nt,lerpAngle:()=>ut,mag:()=>it,makeCircle:()=>bt,makeRectangle:()=>xt,mean:()=>ot,median:()=>nt,mod:()=>rt,range:()=>gt,resolverect:()=>H,scaleImage:()=>ft,shuffle:()=>_t,sum:()=>E,tail:()=>Mt,tintImage:()=>dt,tween:()=>ee,vec:()=>o,vecAbs:()=>Dt,vecAdd:()=>L,vecAngle:()=>Ft,vecAngleBetween:()=>Rt,vecCeil:()=>Xt,vecClamp:()=>Ut,vecCross:()=>Yt,vecDist:()=>Lt,vecDist2:()=>St,vecDiv:()=>A,vecDot:()=>K,vecEq:()=>O,vecFloor:()=>Bt,vecIsZero:()=>Vt,vecLerp:()=>zt,vecLimit:()=>Ot,vecMag:()=>Z,vecMag2:()=>G,vecMove:()=>qt,vecMult:()=>N,vecNorm:()=>F,vecRand:()=>vt,vecReflect:()=>Pt,vecRotate:()=>It,vecRound:()=>Ht,vecSet:()=>$,vecSetMag:()=>Ct,vecSub:()=>S});var y=class{_engine=null;x=0;y=0;ox=0;oy=0;width=0;height=0;rotation=0;scale=1;constructor(t=null,s=0,r=0,a=null,i=null){this._engine=t||globalThis,this.ox=s,this.oy=r,this.resize(a||this._engine.W-s,i||this._engine.H-r),this.x=this.width/2,this.y=this.height/2,this._shake={x:0,y:0,removeListener:null}}resize(t,s){this.width=t,this.height=s,this._engine.emit("camera-resized",this)}start(t=!1){if(this._engine.push(),t){let a=path();a.rect(this.ox,this.oy,this.width,this.height),this._engine.clip(a)}let s=this.ox+this.width/2,r=this.oy+this.height/2;this._engine.translate(s,r),this._engine.scale(this.scale),this._engine.rotate(this.rotation),this._engine.translate(-this.x+this._shake.x,-this.y+this._shake.y)}end(){this._engine.pop()}lookAt(t,s){this.x=t,this.y=s}move(t,s){this.x+=t,this.y+=s}zoom(t){this.scale*=t}zoomTo(t){this.scale=t}rotate(t){this.rotation+=t}rotateTo(t){this.rotation=t}getWorldPoint(t,s,r={}){let a=Math.cos(-this.rotation),i=Math.sin(-this.rotation);return t=(t-this.width/2-this.ox)/this.scale,s=(s-this.height/2-this.oy)/this.scale,r.x=a*t-i*s+this.x,r.y=i*t+a*s+this.y,r}getCameraPoint(t,s,r={}){let a=Math.cos(-this.rotation),i=Math.sin(-this.rotation);return t=t-this.x,s=s-this.y,t=a*t-i*s,s=i*t+a*s,r.x=t*this.scale+this.width/2+this.ox,r.y=s*this.scale+this.height/2+this.oy,r}getBounds(){return[this.ox,this.oy,this.width,this.height]}shake(t=1,s=.3){this.shaking||(this._shake.removeListener=this._engine.listen("update",r=>{this._shake.x=this._engine.randi(-t,t),this._shake.y=this._engine.randi(-t,t),s-=r,s<=0&&this.unshake()}))}unshake(){this.shaking&&(this._shake.removeListener(),this._shake.removeListener=null,this._shake.x=this._shake.y=0)}get shaking(){return this._shake.removeListener!==null}};var T=(e,t,s,r,a,i,n,u)=>{let h=Math.max(e,a),b=Math.min(e+s,a+n)-h,m=Math.max(t,i),x=Math.min(t+r,i+u)-m;return[h,m,b,x]};var H=(e,t,s,r,a,i,n,u)=>{let[h,b,m,x]=T(e,t,s,r,a,i,n,u),d="",_=e,l=t;return m<x?e<a?(d="right",_=a-s):(d="left",_=a+n):t<i?(d="bottom",l=i-r):(d="top",l=i+u),{direction:d,x:_,y:l}};var U=(e,t,s,r,a,i,n,u)=>e<a+n&&e+s>a&&t<i+u&&t+r>i;var q=(e,t,s,r,a,i)=>(r-e)*(r-e)+(a-t)*(a-t)<=(s+i)*(s+i);var k=class e{_w;_h;_c;constructor(t,s,r=[]){this._w=Math.max(1,~~t),this._h=Math.max(1,~~s),this._c=r}[Symbol.iterator](){let t=0;return{next:()=>({value:[this.indexToPointX(t),this.indexToPointY(t),this._c[t++]],done:t>this._c.length})}}clone(){return new e(this._w,this._h,this._c)}clear(){this.forEach((t,s)=>this.set(t,s,void 0))}get width(){return this._w}get height(){return this._h}set(t,s,r){this._c[this.pointToIndex(t,s)]=r}get(t,s){return this._c[this.pointToIndex(t,s)]}has(t,s){return this.get(t,s)!=null}check(t,s){return t>=0&&t<this._w&&s>=0&&s<this._h}get length(){return this._w*this._h}pointToIndex(t,s){return this.clampX(~~t)+this.clampY(~~s)*this._w}indexToPointX(t){return t%this._w}indexToPointY(t){return Math.floor(t/this._w)}forEach(t,s=!1){let r=s?this.length-1:0,a=s?-1:this.length,i=s?-1:1;for(;r!==a;){let n=this.indexToPointX(r),u=this.indexToPointY(r),h=this._c[r];if(t(n,u,h,this)===!1)break;r+=i}}fill(t){this.forEach((s,r)=>{this.set(s,r,t)})}clampX(t){return V(t,0,this._w-1)}clampY(t){return V(t,0,this._h-1)}toArray(){return this._c.slice()}toString(t=" ",s=!0){if(!s)return this._c.join(t);let r=[];return this.forEach((a,i,n)=>{r[i]=r[i]||"",r[i]+=n+t}),r.join(`
2
- `)}},C=class e extends k{constructor(t,s,r=Uint8Array){super(t,s,null),this._c=new r(this._w*this._h)}has(t,s){return this.get(t,s)!==0}clone(){let t=new e(this._w,this._h,this._c.constructor);return this.forEach((s,r,a)=>{t.set(s,r,a)}),t}};function V(e,t,s){return e<t?t:e>s?s:e}var At=Math.sqrt,j=Math.cos,W=Math.sin,Et=2*Math.PI,w=class{x;y;constructor(t=0,s=t){this.x=t,this.y=s}toString(){return`Vector (${this.x}, ${this.y})`}},g=e=>e instanceof w,o=(e=0,t=e)=>(g(e)&&(t=e.y,e=e.x),new w(e,t)),O=(e,t,s=t)=>g(t)?O(e,t.x,t.y):e.x===t&&e.y===s,$=(e,t,s=t)=>(g(t)?$(e,t.x,t.y):(e.x=t,e.y=s),e),L=(e,t,s=t)=>g(t)?L(e,t.x,t.y):(e.x+=t,e.y+=s,e),S=(e,t,s=t)=>g(t)?S(e,t.x,t.y):(e.x-=t,e.y-=s,e),N=(e,t,s=t)=>g(t)?N(e,t.x,t.y):(e.x*=t,e.y*=s,e),A=(e,t,s=t)=>g(t)?A(e,t.x,t.y):(e.x/=t||1,e.y/=s||1,e),It=(e,t)=>{let s=j(t),r=W(t);return e.x=s*e.x-r*e.y,e.y=r*e.x+s*e.y,e},Pt=(e,t)=>{let s=F(o(t));return S(e,N(s,2*K(e,s)))},Ct=(e,t)=>(F(e),N(e,t),e),Z=e=>Math.hypot(e.x,e.y),G=e=>e.x*e.x+e.y*e.y,F=e=>{let t=Z(e);return t>0&&A(e,t),e},Ot=(e,t=1)=>{let s=G(e);return s>t*t&&(A(e,At(s)),N(e,t)),e},Lt=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),St=(e,t)=>{let s=e.x-t.x,r=e.y-t.y;return s*s+r*r},Ft=e=>Math.atan2(e.y,e.x),Rt=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),K=(e,t)=>e.x*t.x+e.y*t.y,Yt=(e,t)=>e.x*t.y-e.y*t.x,zt=(e,t,s)=>(e.x+=(t.x-e.x)*s||0,e.y+=(t.y-e.y)*s||0,e),vt=(e=1,t=e,s=globalThis.rand||Math.random)=>{let r=s()*Et,a=s()*(t-e)+e;return o(j(r)*a,W(r)*a)},Dt=e=>(e.x=Math.abs(e.x),e.y=Math.abs(e.y),e),Xt=e=>(e.x=Math.ceil(e.x),e.y=Math.ceil(e.y),e),Bt=e=>(e.x=Math.floor(e.x),e.y=Math.floor(e.y),e),Ht=e=>(e.x=Math.round(e.x),e.y=Math.round(e.y),e),Ut=(e,t,s)=>(e.x<t.x&&(e.x=t.x),e.x>s.x&&(e.x=s.x),e.y<t.y&&(e.y=t.y),e.y>s.y&&(e.y=s.y),e),qt=(e,t,s=1)=>L(e,t.x*s,t.y*s),Vt=e=>O(e,Q),Q=o(0,0),jt=o(1,1),Wt=o(0,-1),$t=o(1,0),Zt=o(0,1),Gt=o(-1,0);var Kt=o(.5,.5),J=o(0,0),Qt=o(1,0),Jt=o(0,1),te=o(1,1),R=class{sprite;pos;_o;_s;flipX=!1;flipY=!1;angle=0;opacity=1;hidden=!1;constructor(t,s,r=J){this.sprite=t,this.pos=s||o(0),this._o=o(r),this._s=o(1,1)}set x(t){this.pos.x=t}get x(){return this.pos.x}set y(t){this.pos.y=t}get y(){return this.pos.y}set anchor(t){this._o.x=t.x,this._o.y=t.y}get anchor(){return this._o}get width(){return this.sprite.width*this._s.x}get height(){return this.sprite.height*this._s.y}get scale(){return this._s}scaleTo(t,s=t){this._s.x=t,this._s.y=s}scaleBy(t,s=t){this._s.x*=t,this._s.y*=s}getBounds(t=!0){let s=this.sprite.width*(t?this._s.x:1),r=this.sprite.height*(t?this._s.y:1),a=this.pos.x-s*this.anchor.x,i=this.pos.y-r*this.anchor.y;return[a,i,s,r]}draw(t=globalThis,s=!0){this.hidden||this.opacity<=0||(s&&t.push(),this.transform(t),this.drawImage(t),s&&t.pop())}transform(t){t.translate(this.pos.x,this.pos.y),t.rotate(t.deg2rad(this.angle)),t.scale((this.flipX?-1:1)*this._s.x,(this.flipY?-1:1)*this._s.y)}drawImage(t,s=!0){let r=this.anchor,a=-this.sprite.width*(this.flipX?1-r.x:r.x),i=-this.sprite.height*(this.flipY?1-r.y:r.y);s&&t.alpha(this.opacity),t.image(a,i,this.sprite)}};var tt=(e,t)=>Math.abs(t-e)||0;var et=e=>e%1||0;var st=advance=(e,t,s,r=1)=>{s&&(t.x+=s.x*r,t.y+=s.y*r),e.x+=t.x*r,e.y+=t.y*r};var rt=(e,t)=>(t+e%t)%t;var at=(e,t,s,r)=>Math.hypot(s-e,r-t);var it=(e,t)=>Math.hypot(e,t);var E=e=>{let t=0;for(let s=0;s<e.length;s++)t+=e[s];return t};var ot=e=>E(e)/e.length;var nt=(...e)=>{let t=e.sort((r,a)=>r-a),s=Math.floor(t.length/2);return t.length%2===0?(t[s-1]+t[s])/2:t[s]};var ut=(e,t,s)=>{let r=(t-e)%360;return r>180?r-=360:r<-180&&(r+=360),e+r*s};var I=Math.PI/2,ee=(e,t,s,r=1,a=lt)=>new Y(e,t,s,r,a),lt=e=>e,se=e=>e*e,re=e=>-e*(e-2),ae=e=>e<.5?2*e*e:-2*e*e+4*e-1,ie=e=>e*e*e-e*Math.sin(e*Math.PI),oe=e=>{let t=1-e;return 1-(t*t*t-t*Math.sin(t*Math.PI))},ne=e=>{if(e<.5){let s=2*e;return .5*(s*s*s-s*Math.sin(s*Math.PI))}let t=1-(2*e-1);return .5*(1-(t*t*t-t*Math.sin(e*Math.PI)))+.5},ue=e=>Math.sin(13*I*e)*Math.pow(2,10*(e-1)),le=e=>Math.sin(-13*I*(e+1))*Math.pow(2,-10*e)+1,he=e=>{if(e<.5){let r=Math.sin(13*I*(2*e)),a=Math.pow(2,10*(2*e-1));return .5*r*a}let t=Math.sin(-13*I*(2*e-1+1)),s=Math.pow(2,-10*(2*e-1));return .5*(t*s+2)},ht=e=>1-z(1-e),z=e=>e<4/11?121*e*e/16:e<8/11?363/40*e*e-99/10*e+17/5:e<9/10?4356/361*e*e-35442/1805*e+16061/1805:54/5*e*e-513/25*e+268/25,me=e=>e<.5?.5*ht(e*2):.5*z(e*2-1)+.5,Y=class{running=!1;_o;_p;_x;_d;_w;_e;_rel;_cb=[];_t=0;_u=0;_ch=this;_cu=this;_lc;constructor(t,s,r,a,i){this._o=t,this._p=s,this._x=r,this._d=a,this._e=i,this._w=0}start(t){if(this.running)return this;this._cu.stop(!1),this._ch=this._cu=this,this.running=!0;let s=this._o[this._p]||0,r=this._rel?s+this._x:this._x;return this._lc=this._lc||t||globalThis,this._u=this._lc.listen("update",a=>{if(this._t<=this._w){this._t+=a;return}let i=this._t-this._w;this._o[this._p]=this._lc.lerp(s,r,this._e(i/this._d)),this._t+=a,i>=this._d&&(this._o[this._p]=r,this.stop())}),this}stop(t=!0){if(!this._u)return this;if(this.running=!1,this._u(),this._t=0,t)for(let s of this._cb)s(this._o);return this}restart(t=null,s=!1){return this.stop(s).restart(t)}onEnd(t){return this._cb.push(t),this}chain(t){return this._ch.onEnd(()=>{this._cu=t.start(this._lc)}),this._ch=t,this}reset(){return this._cb.length=0,this.stop()}relative(t=!0){return this._rel=t,this}delay(t){return this._w=t,this}get current(){return this._cu}get progress(){return this.running&&this._t>this._w?(this._t-this._w)/this._d:0}};var mt=4,P=1<<mt,ct=8,ce=1<<ct,f=4095,v=e=>.5*(1-Math.cos(e*Math.PI)),D=class{_p=[];_po=4;_pf=.5;_e=null;constructor(t){this._e=t||globalThis,this.noiseSeed()}noise(t,s=0,r=0){t<0&&(t=-t),s<0&&(s=-s),r<0&&(r=-r);let a=Math.floor(t),i=Math.floor(s),n=Math.floor(r),u=t-a,h=s-i,b=r-n,m,x,d=0,_=.5,l,c,M;for(let B=0;B<this._po;B++){let p=a+(i<<mt)+(n<<ct);m=v(u),x=v(h),l=this._p[p&f],l+=m*(this._p[p+1&f]-l),c=this._p[p+P&f],c+=m*(this._p[p+P+1&f]-c),l+=x*(c-l),p+=ce,c=this._p[p&f],c+=m*(this._p[p+1&f]-c),M=this._p[p+P&f],M+=m*(this._p[p+P+1&f]-M),c+=x*(M-c),l+=v(b)*(c-l),d+=l*_,_*=this._pf,a<<=1,u*=2,i<<=1,h*=2,n<<=1,b*=2,u>=1&&(a++,u--),h>=1&&(i++,h--),b>=1&&(n++,b--)}return d}noiseDetail(t,s){t>0&&(this._po=t),s>0&&(this._pf=s)}noiseSeed(t=null){t!=null&&this._e.rseed(t);let s=this._e.rand||Math.random;for(let r=0;r<f+1;r++)this._p[r]=s()}};var pt=(e,t=!0,s=!1,r=globalThis)=>r.paint(e.width,e.height,a=>{r.push(),r.scale(t?-1:1,s?-1:1),r.image(t?-e.width:0,s?-e.height:0,e),r.pop()});var ft=(e,t,s=!0,r=globalThis)=>r.paint(e.width*t,e.height*t,a=>{r.push(),a.imageSmoothingEnabled=!s,r.scale(t),r.image(0,0,e),r.pop()});var dt=(e,t,s=1,r=globalThis)=>r.paint(e.width,e.height,a=>{r.push(),r.alpha(s),r.rectfill(0,0,e.width,e.height,t),a.globalCompositeOperation="destination-atop",r.alpha(1),r.image(0,0,e),r.pop()});var bt=(e,t,{borderWidth:s=0,borderColor:r=0,engine:a=globalThis}={})=>{let i=e*2+s;return a.paint(i,i,()=>{a.circfill(i/2,i/2,e,t),s>0&&(a.linewidth(s),a.stroke(r))})};var xt=(e,t,s,{borderWidth:r=0,borderColor:a=0,engine:i=globalThis}={})=>{let n=e+r*2,u=t+r*2;return i.paint(n,u,()=>{i.rectfill(r>0?r:0,r>0?r:0,e,t,s),r>0&&(i.linewidth(r),i.stroke(a))})};var gt=(e,t=0,s=1)=>[...new Array(e).keys()].map(r=>t+s*r);var _t=(e,t=globalThis.rand||Math.random)=>{e=[...e];for(let s=e.length-1;s>0;s--){let r=Math.floor(t()*(s+1)),a=e[s];e[s]=e[r],e[r]=a}return e};var yt=(e,t=globalThis.rand||Math.random)=>e[Math.floor(t()*e.length)];var wt=e=>e[0];var Nt=e=>e[e.length-1];var Mt=e=>e.slice(1);globalThis.utils=Object.assign(globalThis.utils||{},X);})();
1
+ (()=>{var Tt=Object.defineProperty;var kt=(e,t)=>{for(var s in t)Tt(e,s,{get:t[s],enumerable:!0})};globalThis.utils=globalThis.utils||{};globalThis.utils.global=(e=!0)=>{for(let t in globalThis.utils)t!=="global"&&(e||globalThis[t]===void 0)&&(globalThis[t]=globalThis.utils[t])};var X={};kt(X,{ANCHOR_BOT_LEFT:()=>Jt,ANCHOR_BOT_RIGHT:()=>te,ANCHOR_CENTER:()=>Kt,ANCHOR_TOP_LEFT:()=>J,ANCHOR_TOP_RIGHT:()=>Qt,Actor:()=>S,BACK_IN:()=>ie,BACK_IN_OUT:()=>ne,BACK_OUT:()=>oe,BOUNCE_IN:()=>ht,BOUNCE_IN_OUT:()=>me,BOUNCE_OUT:()=>z,Camera:()=>y,DOWN:()=>$t,EASE_IN:()=>se,EASE_IN_OUT:()=>ae,EASE_OUT:()=>re,ELASTIC_IN:()=>ue,ELASTIC_IN_OUT:()=>he,ELASTIC_OUT:()=>le,Grid:()=>k,LEFT:()=>Gt,LINEAR:()=>lt,Noise:()=>Y,ONE:()=>Vt,RIGHT:()=>Zt,TypedGrid:()=>C,UP:()=>Wt,Vector:()=>w,ZERO:()=>Q,advance:()=>st,choose:()=>yt,colcirc:()=>j,colrect:()=>U,diff:()=>tt,dist:()=>at,flipImage:()=>pt,fract:()=>et,head:()=>wt,intersection:()=>T,last:()=>Nt,lerpAngle:()=>ut,mag:()=>it,makeCircle:()=>dt,makeRectangle:()=>xt,mean:()=>ot,median:()=>nt,mod:()=>rt,range:()=>gt,resolverect:()=>B,scaleImage:()=>ft,shuffle:()=>_t,sum:()=>A,tail:()=>Mt,tintImage:()=>bt,tween:()=>ee,vec:()=>o,vecAbs:()=>Yt,vecAdd:()=>O,vecAngle:()=>vt,vecAngleBetween:()=>St,vecCeil:()=>Xt,vecClamp:()=>Ut,vecCross:()=>Rt,vecDist:()=>Ot,vecDist2:()=>Ft,vecDiv:()=>E,vecDot:()=>K,vecEq:()=>L,vecFloor:()=>Ht,vecIsZero:()=>qt,vecLerp:()=>zt,vecLimit:()=>Lt,vecMag:()=>$,vecMag2:()=>G,vecMove:()=>jt,vecMult:()=>N,vecNorm:()=>v,vecRand:()=>Dt,vecReflect:()=>Pt,vecRotate:()=>It,vecRound:()=>Bt,vecSet:()=>Z,vecSetMag:()=>Ct,vecSub:()=>F});var y=class{_engine=null;x=0;y=0;ox=0;oy=0;width=0;height=0;rotation=0;scale=1;constructor(t=null,s=0,r=0,a=null,i=null){this._engine=t||globalThis,this.ox=s,this.oy=r,this.resize(a||this._engine.W-s,i||this._engine.H-r),this.x=this.width/2,this.y=this.height/2,this._shake={x:0,y:0,removeListener:null}}resize(t,s){this.width=t,this.height=s,this._engine.emit("camera-resized",this)}start(t=!1){if(this._engine.push(),t){let a=path();a.rect(this.ox,this.oy,this.width,this.height),this._engine.clip(a)}let s=this.ox+this.width/2,r=this.oy+this.height/2;this._engine.translate(s,r),this._engine.scale(this.scale),this._engine.rotate(this.rotation),this._engine.translate(-this.x+this._shake.x,-this.y+this._shake.y)}end(){this._engine.pop()}lookAt(t,s){this.x=t,this.y=s}move(t,s){this.x+=t,this.y+=s}zoom(t){this.scale*=t}zoomTo(t){this.scale=t}rotate(t){this.rotation+=t}rotateTo(t){this.rotation=t}getWorldPoint(t,s,r={}){let a=Math.cos(-this.rotation),i=Math.sin(-this.rotation);return t=(t-this.width/2-this.ox)/this.scale,s=(s-this.height/2-this.oy)/this.scale,r.x=a*t-i*s+this.x,r.y=i*t+a*s+this.y,r}getCameraPoint(t,s,r={}){let a=Math.cos(-this.rotation),i=Math.sin(-this.rotation);return t=t-this.x,s=s-this.y,t=a*t-i*s,s=i*t+a*s,r.x=t*this.scale+this.width/2+this.ox,r.y=s*this.scale+this.height/2+this.oy,r}getBounds(){return[this.ox,this.oy,this.width,this.height]}shake(t=1,s=.3){this.shaking||(this._shake.removeListener=this._engine.listen("update",r=>{this._shake.x=this._engine.randi(-t,t),this._shake.y=this._engine.randi(-t,t),s-=r,s<=0&&this.unshake()}))}unshake(){this.shaking&&(this._shake.removeListener(),this._shake.removeListener=null,this._shake.x=this._shake.y=0)}get shaking(){return this._shake.removeListener!==null}};var T=(e,t,s,r,a,i,n,u)=>{let h=Math.max(e,a),d=Math.min(e+s,a+n)-h,m=Math.max(t,i),x=Math.min(t+r,i+u)-m;return[h,m,d,x]};var B=(e,t,s,r,a,i,n,u)=>{let[h,d,m,x]=T(e,t,s,r,a,i,n,u),b="",_=e,l=t;return m<x?e<a?(b="right",_=a-s):(b="left",_=a+n):t<i?(b="bottom",l=i-r):(b="top",l=i+u),{direction:b,x:_,y:l}};var U=(e,t,s,r,a,i,n,u)=>e<a+n&&e+s>a&&t<i+u&&t+r>i;var j=(e,t,s,r,a,i)=>(r-e)*(r-e)+(a-t)*(a-t)<=(s+i)*(s+i);var k=class e{_w;_h;_c;constructor(t,s,r=[]){this._w=Math.max(1,~~t),this._h=Math.max(1,~~s),this._c=r}[Symbol.iterator](){let t=0;return{next:()=>({value:[this.indexToPointX(t),this.indexToPointY(t),this._c[t++]],done:t>this._c.length})}}clone(){return new e(this._w,this._h,this._c)}clear(){this.forEach((t,s)=>this.set(t,s,void 0))}get width(){return this._w}get height(){return this._h}set(t,s,r){this._c[this.pointToIndex(t,s)]=r}get(t,s){return this._c[this.pointToIndex(t,s)]}has(t,s){return this.get(t,s)!=null}check(t,s){return t>=0&&t<this._w&&s>=0&&s<this._h}get length(){return this._w*this._h}pointToIndex(t,s){return this.clampX(~~t)+this.clampY(~~s)*this._w}indexToPointX(t){return t%this._w}indexToPointY(t){return Math.floor(t/this._w)}forEach(t,s=!1){let r=s?this.length-1:0,a=s?-1:this.length,i=s?-1:1;for(;r!==a;){let n=this.indexToPointX(r),u=this.indexToPointY(r),h=this._c[r];if(t(n,u,h,this)===!1)break;r+=i}}fill(t){this.forEach((s,r)=>{this.set(s,r,t)})}clampX(t){return q(t,0,this._w-1)}clampY(t){return q(t,0,this._h-1)}toArray(){return this._c.slice()}toString(t=" ",s=!0){if(!s)return this._c.join(t);let r=[];return this.forEach((a,i,n)=>{r[i]=r[i]||"",r[i]+=n+t}),r.join(`
2
+ `)}},C=class e extends k{constructor(t,s,r=Uint8Array){super(t,s,null),this._c=new r(this._w*this._h)}has(t,s){return this.get(t,s)!==0}clone(){let t=new e(this._w,this._h,this._c.constructor);return this.forEach((s,r,a)=>{t.set(s,r,a)}),t}};function q(e,t,s){return e<t?t:e>s?s:e}var Et=Math.sqrt,V=Math.cos,W=Math.sin,At=2*Math.PI,w=class{x;y;constructor(t=0,s=t){this.x=t,this.y=s}toString(){return`Vector (${this.x}, ${this.y})`}},g=e=>e instanceof w,o=(e=0,t=e)=>(g(e)&&(t=e.y,e=e.x),new w(e,t)),L=(e,t,s=t)=>g(t)?L(e,t.x,t.y):e.x===t&&e.y===s,Z=(e,t,s=t)=>(g(t)?Z(e,t.x,t.y):(e.x=t,e.y=s),e),O=(e,t,s=t)=>g(t)?O(e,t.x,t.y):(e.x+=t,e.y+=s,e),F=(e,t,s=t)=>g(t)?F(e,t.x,t.y):(e.x-=t,e.y-=s,e),N=(e,t,s=t)=>g(t)?N(e,t.x,t.y):(e.x*=t,e.y*=s,e),E=(e,t,s=t)=>g(t)?E(e,t.x,t.y):(e.x/=t||1,e.y/=s||1,e),It=(e,t)=>{let s=V(t),r=W(t);return e.x=s*e.x-r*e.y,e.y=r*e.x+s*e.y,e},Pt=(e,t)=>{let s=v(o(t));return F(e,N(s,2*K(e,s)))},Ct=(e,t)=>(v(e),N(e,t),e),$=e=>Math.hypot(e.x,e.y),G=e=>e.x*e.x+e.y*e.y,v=e=>{let t=$(e);return t>0&&E(e,t),e},Lt=(e,t=1)=>{let s=G(e);return s>t*t&&(E(e,Et(s)),N(e,t)),e},Ot=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),Ft=(e,t)=>{let s=e.x-t.x,r=e.y-t.y;return s*s+r*r},vt=e=>Math.atan2(e.y,e.x),St=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),K=(e,t)=>e.x*t.x+e.y*t.y,Rt=(e,t)=>e.x*t.y-e.y*t.x,zt=(e,t,s)=>(e.x+=(t.x-e.x)*s||0,e.y+=(t.y-e.y)*s||0,e),Dt=(e=1,t=e,s=globalThis.rand||Math.random)=>{let r=s()*At,a=s()*(t-e)+e;return o(V(r)*a,W(r)*a)},Yt=e=>(e.x=Math.abs(e.x),e.y=Math.abs(e.y),e),Xt=e=>(e.x=Math.ceil(e.x),e.y=Math.ceil(e.y),e),Ht=e=>(e.x=Math.floor(e.x),e.y=Math.floor(e.y),e),Bt=e=>(e.x=Math.round(e.x),e.y=Math.round(e.y),e),Ut=(e,t,s)=>(e.x<t.x&&(e.x=t.x),e.x>s.x&&(e.x=s.x),e.y<t.y&&(e.y=t.y),e.y>s.y&&(e.y=s.y),e),jt=(e,t,s=1)=>O(e,t.x*s,t.y*s),qt=e=>L(e,Q),Q=o(0,0),Vt=o(1,1),Wt=o(0,-1),Zt=o(1,0),$t=o(0,1),Gt=o(-1,0);var Kt=o(.5,.5),J=o(0,0),Qt=o(1,0),Jt=o(0,1),te=o(1,1),S=class{sprite;pos;_o;_s;flipX=!1;flipY=!1;angle=0;opacity=1;hidden=!1;constructor(t,s,r=J){this.sprite=t,this.pos=s||o(0),this._o=o(r),this._s=o(1,1)}set x(t){this.pos.x=t}get x(){return this.pos.x}set y(t){this.pos.y=t}get y(){return this.pos.y}set anchor(t){this._o.x=t.x,this._o.y=t.y}get anchor(){return this._o}get width(){return this.sprite.width*this._s.x}get height(){return this.sprite.height*this._s.y}get scale(){return this._s}scaleTo(t,s=t){this._s.x=t,this._s.y=s}scaleBy(t,s=t){this._s.x*=t,this._s.y*=s}getBounds(t=!0){let s=this.sprite.width*(t?this._s.x:1),r=this.sprite.height*(t?this._s.y:1),a=this.pos.x-s*this.anchor.x,i=this.pos.y-r*this.anchor.y;return[a,i,s,r]}draw(t=globalThis,s=!0){this.hidden||this.opacity<=0||(s&&t.push(),this.transform(t),this.drawImage(t),s&&t.pop())}transform(t){t.translate(this.pos.x,this.pos.y),t.rotate(t.deg2rad(this.angle)),t.scale((this.flipX?-1:1)*this._s.x,(this.flipY?-1:1)*this._s.y)}drawImage(t,s=!0){let r=this.anchor,a=-this.sprite.width*(this.flipX?1-r.x:r.x),i=-this.sprite.height*(this.flipY?1-r.y:r.y);s&&t.alpha(this.opacity),t.image(a,i,this.sprite)}};var tt=(e,t)=>Math.abs(t-e)||0;var et=e=>e%1||0;var st=advance=(e,t,s,r=1)=>{s&&(t.x+=s.x*r,t.y+=s.y*r),e.x+=t.x*r,e.y+=t.y*r};var rt=(e,t)=>(t+e%t)%t;var at=(e,t,s,r)=>Math.hypot(s-e,r-t);var it=(e,t)=>Math.hypot(e,t);var A=e=>{let t=0;for(let s=0;s<e.length;s++)t+=e[s];return t};var ot=e=>A(e)/e.length;var nt=(...e)=>{let t=e.sort((r,a)=>r-a),s=Math.floor(t.length/2);return t.length%2===0?(t[s-1]+t[s])/2:t[s]};var ut=(e,t,s)=>{let r=(t-e)%360;return r>180?r-=360:r<-180&&(r+=360),e+r*s};var I=Math.PI/2,ee=(e,t,s,r=1,a=lt)=>new R(e,t,s,r,a),lt=e=>e,se=e=>e*e,re=e=>-e*(e-2),ae=e=>e<.5?2*e*e:-2*e*e+4*e-1,ie=e=>e*e*e-e*Math.sin(e*Math.PI),oe=e=>{let t=1-e;return 1-(t*t*t-t*Math.sin(t*Math.PI))},ne=e=>{if(e<.5){let s=2*e;return .5*(s*s*s-s*Math.sin(s*Math.PI))}let t=1-(2*e-1);return .5*(1-(t*t*t-t*Math.sin(e*Math.PI)))+.5},ue=e=>Math.sin(13*I*e)*Math.pow(2,10*(e-1)),le=e=>Math.sin(-13*I*(e+1))*Math.pow(2,-10*e)+1,he=e=>{if(e<.5){let r=Math.sin(13*I*(2*e)),a=Math.pow(2,10*(2*e-1));return .5*r*a}let t=Math.sin(-13*I*(2*e-1+1)),s=Math.pow(2,-10*(2*e-1));return .5*(t*s+2)},ht=e=>1-z(1-e),z=e=>e<4/11?121*e*e/16:e<8/11?363/40*e*e-99/10*e+17/5:e<9/10?4356/361*e*e-35442/1805*e+16061/1805:54/5*e*e-513/25*e+268/25,me=e=>e<.5?.5*ht(e*2):.5*z(e*2-1)+.5,R=class{running=!1;_o;_p;_x;_d;_w;_e;_rel;_cb=[];_t=0;_u=0;_ch=this;_cu=this;_lc;constructor(t,s,r,a,i){this._o=t,this._p=s,this._x=r,this._d=a,this._e=i,this._w=0}start(t){if(this.running)return this;this._cu.stop(!1),this._ch=this._cu=this,this.running=!0;let s=this._o[this._p]||0,r=this._rel?s+this._x:this._x;return this._lc=this._lc||t||globalThis,this._u=this._lc.listen("update",a=>{if(this._t<=this._w){this._t+=a;return}let i=this._t-this._w;this._o[this._p]=this._lc.lerp(s,r,this._e(i/this._d)),this._t+=a,i>=this._d&&(this._o[this._p]=r,this.stop())}),this}stop(t=!0){if(!this._u)return this;if(this.running=!1,this._u(),this._t=0,t)for(let s of this._cb)s(this._o);return this}restart(t=null,s=!1){return this.stop(s).restart(t)}onEnd(t){return this._cb.push(t),this}chain(t){return this._ch.onEnd(()=>{this._cu=t.start(this._lc)}),this._ch=t,this}reset(){return this._cb.length=0,this.stop()}relative(t=!0){return this._rel=t,this}delay(t){return this._w=t,this}get current(){return this._cu}get progress(){return this.running&&this._t>this._w?(this._t-this._w)/this._d:0}};var mt=4,P=1<<mt,ct=8,ce=1<<ct,f=4095,D=e=>.5*(1-Math.cos(e*Math.PI)),Y=class{_p=[];_po=4;_pf=.5;_e=null;constructor(t){this._e=t||globalThis,this.noiseSeed()}noise(t,s=0,r=0){t<0&&(t=-t),s<0&&(s=-s),r<0&&(r=-r);let a=Math.floor(t),i=Math.floor(s),n=Math.floor(r),u=t-a,h=s-i,d=r-n,m,x,b=0,_=.5,l,c,M;for(let H=0;H<this._po;H++){let p=a+(i<<mt)+(n<<ct);m=D(u),x=D(h),l=this._p[p&f],l+=m*(this._p[p+1&f]-l),c=this._p[p+P&f],c+=m*(this._p[p+P+1&f]-c),l+=x*(c-l),p+=ce,c=this._p[p&f],c+=m*(this._p[p+1&f]-c),M=this._p[p+P&f],M+=m*(this._p[p+P+1&f]-M),c+=x*(M-c),l+=D(d)*(c-l),b+=l*_,_*=this._pf,a<<=1,u*=2,i<<=1,h*=2,n<<=1,d*=2,u>=1&&(a++,u--),h>=1&&(i++,h--),d>=1&&(n++,d--)}return b}noiseDetail(t,s){t>0&&(this._po=t),s>0&&(this._pf=s)}noiseSeed(t=null){t!=null&&this._e.rseed(t);let s=this._e.rand||Math.random;for(let r=0;r<f+1;r++)this._p[r]=s()}};var pt=(e,t=!0,s=!1,r=globalThis)=>r.paint(e.width,e.height,a=>{r.push(),r.scale(t?-1:1,s?-1:1),r.image(t?-e.width:0,s?-e.height:0,e),r.pop()});var ft=(e,t,s=!0,r=globalThis)=>r.paint(e.width*t,e.height*t,a=>{r.push(),a.imageSmoothingEnabled=!s,r.scale(t),r.image(0,0,e),r.pop()});var bt=(e,t,s=1,r=globalThis)=>r.paint(e.width,e.height,a=>{r.push(),r.alpha(s),r.rectfill(0,0,e.width,e.height,t),a.globalCompositeOperation="destination-atop",r.alpha(1),r.image(0,0,e),r.pop()});var dt=(e,t,{borderWidth:s=0,borderColor:r=0,engine:a=globalThis}={})=>{let i=e*2+s;return a.paint(i,i,()=>{a.circfill(i/2,i/2,e,t),s>0&&(a.linewidth(s),a.stroke(r))})};var xt=(e,t,s,{borderWidth:r=0,borderColor:a=0,engine:i=globalThis}={})=>{let n=e+r*2,u=t+r*2;return i.paint(n,u,()=>{i.rectfill(r>0?r:0,r>0?r:0,e,t,s),r>0&&(i.linewidth(r),i.stroke(a))})};var gt=(e,t=0,s=1)=>[...new Array(e).keys()].map(r=>t+s*r);var _t=(e,t=globalThis.rand||Math.random)=>{e=[...e];for(let s=e.length-1;s>0;s--){let r=Math.floor(t()*(s+1)),a=e[s];e[s]=e[r],e[r]=a}return e};var yt=(e,t=globalThis.rand||Math.random)=>e[Math.floor(t()*e.length)];var wt=e=>e[0];var Nt=e=>e[e.length-1];var Mt=e=>e.slice(1);globalThis.utils=Object.assign(globalThis.utils||{},X);})();
3
3
  /*! @litecanvas/utils by Luiz Bills | MIT Licensed */
package/dist/noise.min.js CHANGED
@@ -1 +1 @@
1
- (()=>{var T=Object.defineProperty;var E=(o,e)=>{for(var t in e)T(o,t,{get:e[t],enumerable:!0})};globalThis.utils=globalThis.utils||{};globalThis.utils.global=(o=!0)=>{for(let e in globalThis.utils)e!=="global"&&(o||globalThis[e]===void 0)&&(globalThis[e]=globalThis.utils[e])};var v={};E(v,{Noise:()=>y});var k=4,h=1<<k,A=8,P=1<<A,i=4095,N=o=>.5*(1-Math.cos(o*Math.PI)),y=class{_p=[];_po=4;_pf=.5;_e=null;constructor(e){this._e=e||globalThis,this.noiseSeed()}noise(e,t=0,r=0){e<0&&(e=-e),t<0&&(t=-t),r<0&&(r=-r);let m=Math.floor(e),l=Math.floor(t),p=Math.floor(r),b=e-m,c=t-l,f=r-p,u,g,x=0,w=.5,n,a,d;for(let _=0;_<this._po;_++){let s=m+(l<<k)+(p<<A);u=N(b),g=N(c),n=this._p[s&i],n+=u*(this._p[s+1&i]-n),a=this._p[s+h&i],a+=u*(this._p[s+h+1&i]-a),n+=g*(a-n),s+=P,a=this._p[s&i],a+=u*(this._p[s+1&i]-a),d=this._p[s+h&i],d+=u*(this._p[s+h+1&i]-d),a+=g*(d-a),n+=N(f)*(a-n),x+=n*w,w*=this._pf,m<<=1,b*=2,l<<=1,c*=2,p<<=1,f*=2,b>=1&&(m++,b--),c>=1&&(l++,c--),f>=1&&(p++,f--)}return x}noiseDetail(e,t){e>0&&(this._po=e),t>0&&(this._pf=t)}noiseSeed(e=null){e!=null&&this._e.rseed(e);let t=this._e.rand||Math.random;for(let r=0;r<i+1;r++)this._p[r]=t()}};globalThis.utils=Object.assign(globalThis.utils||{},v);})();
1
+ (()=>{var E=Object.defineProperty;var T=(o,e)=>{for(var t in e)E(o,t,{get:e[t],enumerable:!0})};globalThis.utils=globalThis.utils||{};globalThis.utils.global=(o=!0)=>{for(let e in globalThis.utils)e!=="global"&&(o||globalThis[e]===void 0)&&(globalThis[e]=globalThis.utils[e])};var v={};T(v,{Noise:()=>N});var k=4,h=1<<k,A=8,P=1<<A,n=4095,y=o=>.5*(1-Math.cos(o*Math.PI)),N=class{_p=[];_po=4;_pf=.5;_e=null;constructor(e){this._e=e||globalThis,this.noiseSeed()}noise(e,t=0,s=0){e<0&&(e=-e),t<0&&(t=-t),s<0&&(s=-s);let m=Math.floor(e),l=Math.floor(t),p=Math.floor(s),b=e-m,c=t-l,f=s-p,u,g,w=0,x=.5,i,a,d;for(let _=0;_<this._po;_++){let r=m+(l<<k)+(p<<A);u=y(b),g=y(c),i=this._p[r&n],i+=u*(this._p[r+1&n]-i),a=this._p[r+h&n],a+=u*(this._p[r+h+1&n]-a),i+=g*(a-i),r+=P,a=this._p[r&n],a+=u*(this._p[r+1&n]-a),d=this._p[r+h&n],d+=u*(this._p[r+h+1&n]-d),a+=g*(d-a),i+=y(f)*(a-i),w+=i*x,x*=this._pf,m<<=1,b*=2,l<<=1,c*=2,p<<=1,f*=2,b>=1&&(m++,b--),c>=1&&(l++,c--),f>=1&&(p++,f--)}return w}noiseDetail(e,t){e>0&&(this._po=e),t>0&&(this._pf=t)}noiseSeed(e=null){e!=null&&this._e.rseed(e);let t=this._e.rand||Math.random;for(let s=0;s<n+1;s++)this._p[s]=t()}};globalThis.utils=Object.assign(globalThis.utils||{},v);})();
package/dist/tween.min.js CHANGED
@@ -1 +1 @@
1
- (()=>{var c=Object.defineProperty;var b=(e,t)=>{for(var r in t)c(e,r,{get:t[r],enumerable:!0})};globalThis.utils=globalThis.utils||{};globalThis.utils.global=(e=!0)=>{for(let t in globalThis.utils)t!=="global"&&(e||globalThis[t]===void 0)&&(globalThis[t]=globalThis.utils[t])};var m={};b(m,{BACK_IN:()=>_,BACK_IN_OUT:()=>y,BACK_OUT:()=>N,BOUNCE_IN:()=>p,BOUNCE_IN_OUT:()=>A,BOUNCE_OUT:()=>o,EASE_IN:()=>f,EASE_IN_OUT:()=>g,EASE_OUT:()=>d,ELASTIC_IN:()=>x,ELASTIC_IN_OUT:()=>v,ELASTIC_OUT:()=>w,LINEAR:()=>l,tween:()=>h});var n=Math.PI/2,h=(e,t,r,s=1,a=l)=>new u(e,t,r,s,a),l=e=>e,f=e=>e*e,d=e=>-e*(e-2),g=e=>e<.5?2*e*e:-2*e*e+4*e-1,_=e=>e*e*e-e*Math.sin(e*Math.PI),N=e=>{let t=1-e;return 1-(t*t*t-t*Math.sin(t*Math.PI))},y=e=>{if(e<.5){let r=2*e;return .5*(r*r*r-r*Math.sin(r*Math.PI))}let t=1-(2*e-1);return .5*(1-(t*t*t-t*Math.sin(e*Math.PI)))+.5},x=e=>Math.sin(13*n*e)*Math.pow(2,10*(e-1)),w=e=>Math.sin(-13*n*(e+1))*Math.pow(2,-10*e)+1,v=e=>{if(e<.5){let s=Math.sin(13*n*(2*e)),a=Math.pow(2,10*(2*e-1));return .5*s*a}let t=Math.sin(-13*n*(2*e-1+1)),r=Math.pow(2,-10*(2*e-1));return .5*(t*r+2)},p=e=>1-o(1-e),o=e=>e<4/11?121*e*e/16:e<8/11?363/40*e*e-99/10*e+17/5:e<9/10?4356/361*e*e-35442/1805*e+16061/1805:54/5*e*e-513/25*e+268/25,A=e=>e<.5?.5*p(e*2):.5*o(e*2-1)+.5,u=class{running=!1;_o;_p;_x;_d;_w;_e;_rel;_cb=[];_t=0;_u=0;_ch=this;_cu=this;_lc;constructor(t,r,s,a,i){this._o=t,this._p=r,this._x=s,this._d=a,this._e=i,this._w=0}start(t){if(this.running)return this;this._cu.stop(!1),this._ch=this._cu=this,this.running=!0;let r=this._o[this._p]||0,s=this._rel?r+this._x:this._x;return this._lc=this._lc||t||globalThis,this._u=this._lc.listen("update",a=>{if(this._t<=this._w){this._t+=a;return}let i=this._t-this._w;this._o[this._p]=this._lc.lerp(r,s,this._e(i/this._d)),this._t+=a,i>=this._d&&(this._o[this._p]=s,this.stop())}),this}stop(t=!0){if(!this._u)return this;if(this.running=!1,this._u(),this._t=0,t)for(let r of this._cb)r(this._o);return this}restart(t=null,r=!1){return this.stop(r).restart(t)}onEnd(t){return this._cb.push(t),this}chain(t){return this._ch.onEnd(()=>{this._cu=t.start(this._lc)}),this._ch=t,this}reset(){return this._cb.length=0,this.stop()}relative(t=!0){return this._rel=t,this}delay(t){return this._w=t,this}get current(){return this._cu}get progress(){return this.running&&this._t>this._w?(this._t-this._w)/this._d:0}};globalThis.utils=Object.assign(globalThis.utils||{},m);})();
1
+ (()=>{var b=Object.defineProperty;var c=(e,t)=>{for(var s in t)b(e,s,{get:t[s],enumerable:!0})};globalThis.utils=globalThis.utils||{};globalThis.utils.global=(e=!0)=>{for(let t in globalThis.utils)t!=="global"&&(e||globalThis[t]===void 0)&&(globalThis[t]=globalThis.utils[t])};var m={};c(m,{BACK_IN:()=>_,BACK_IN_OUT:()=>y,BACK_OUT:()=>N,BOUNCE_IN:()=>p,BOUNCE_IN_OUT:()=>T,BOUNCE_OUT:()=>o,EASE_IN:()=>f,EASE_IN_OUT:()=>g,EASE_OUT:()=>d,ELASTIC_IN:()=>w,ELASTIC_IN_OUT:()=>v,ELASTIC_OUT:()=>x,LINEAR:()=>l,tween:()=>h});var n=Math.PI/2,h=(e,t,s,r=1,a=l)=>new u(e,t,s,r,a),l=e=>e,f=e=>e*e,d=e=>-e*(e-2),g=e=>e<.5?2*e*e:-2*e*e+4*e-1,_=e=>e*e*e-e*Math.sin(e*Math.PI),N=e=>{let t=1-e;return 1-(t*t*t-t*Math.sin(t*Math.PI))},y=e=>{if(e<.5){let s=2*e;return .5*(s*s*s-s*Math.sin(s*Math.PI))}let t=1-(2*e-1);return .5*(1-(t*t*t-t*Math.sin(e*Math.PI)))+.5},w=e=>Math.sin(13*n*e)*Math.pow(2,10*(e-1)),x=e=>Math.sin(-13*n*(e+1))*Math.pow(2,-10*e)+1,v=e=>{if(e<.5){let r=Math.sin(13*n*(2*e)),a=Math.pow(2,10*(2*e-1));return .5*r*a}let t=Math.sin(-13*n*(2*e-1+1)),s=Math.pow(2,-10*(2*e-1));return .5*(t*s+2)},p=e=>1-o(1-e),o=e=>e<4/11?121*e*e/16:e<8/11?363/40*e*e-99/10*e+17/5:e<9/10?4356/361*e*e-35442/1805*e+16061/1805:54/5*e*e-513/25*e+268/25,T=e=>e<.5?.5*p(e*2):.5*o(e*2-1)+.5,u=class{running=!1;_o;_p;_x;_d;_w;_e;_rel;_cb=[];_t=0;_u=0;_ch=this;_cu=this;_lc;constructor(t,s,r,a,i){this._o=t,this._p=s,this._x=r,this._d=a,this._e=i,this._w=0}start(t){if(this.running)return this;this._cu.stop(!1),this._ch=this._cu=this,this.running=!0;let s=this._o[this._p]||0,r=this._rel?s+this._x:this._x;return this._lc=this._lc||t||globalThis,this._u=this._lc.listen("update",a=>{if(this._t<=this._w){this._t+=a;return}let i=this._t-this._w;this._o[this._p]=this._lc.lerp(s,r,this._e(i/this._d)),this._t+=a,i>=this._d&&(this._o[this._p]=r,this.stop())}),this}stop(t=!0){if(!this._u)return this;if(this.running=!1,this._u(),this._t=0,t)for(let s of this._cb)s(this._o);return this}restart(t=null,s=!1){return this.stop(s).restart(t)}onEnd(t){return this._cb.push(t),this}chain(t){return this._ch.onEnd(()=>{this._cu=t.start(this._lc)}),this._ch=t,this}reset(){return this._cb.length=0,this.stop()}relative(t=!0){return this._rel=t,this}delay(t){return this._w=t,this}get current(){return this._cu}get progress(){return this.running&&this._t>this._w?(this._t-this._w)/this._d:0}};globalThis.utils=Object.assign(globalThis.utils||{},m);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litecanvas/utils",
3
- "version": "0.34.0",
3
+ "version": "0.35.1",
4
4
  "description": "Utilities to help build litecanvas games",
5
5
  "author": "Luiz Bills <luizbills@pm.me>",
6
6
  "license": "MIT",
@@ -1,4 +1,4 @@
1
- import assert from "../debug/assert"
1
+ import assert from "../debug/assert.js"
2
2
 
3
3
  /**
4
4
  * Check a collision between two circles
@@ -1,4 +1,4 @@
1
- import assert from "../debug/assert"
1
+ import assert from "../debug/assert.js"
2
2
 
3
3
  /**
4
4
  * Check a collision between two rectangles
@@ -1,4 +1,4 @@
1
- import intersection from "./intersection"
1
+ import intersection from "./intersection.js"
2
2
  /**
3
3
  * Determines the direction of the collision between two rectangles and
4
4
  * the new position of the first rectangle to be adjusted.
@@ -56,7 +56,7 @@ import { vec, advance } from "@litecanvas/utils"
56
56
  litecanvas()
57
57
 
58
58
  function init() {
59
- pos = vec(0, CY)
59
+ pos = vec(0, H / 2)
60
60
  vel = vec(0, 0)
61
61
  acc = vec(100, 0)
62
62
  }
@@ -1,4 +1,4 @@
1
- import { Vector } from "../vector"
1
+ import { Vector } from "../vector/index.js"
2
2
 
3
3
  /**
4
4
  * Move a vector (position) using another vectors: velocity and acceleration (optional).
package/src/math/mean.js CHANGED
@@ -1,4 +1,4 @@
1
- import sum from "./sum"
1
+ import sum from "./sum.js"
2
2
 
3
3
  /**
4
4
  * Computes the mean of the values in a array.
@@ -33,7 +33,7 @@ litecanvas()
33
33
  function init() {
34
34
  pos = {
35
35
  x: 100,
36
- y: CY,
36
+ y: H / 2,
37
37
  }
38
38
 
39
39
  // create the animation
@@ -221,7 +221,7 @@ litecanvas()
221
221
  function init() {
222
222
  pos = {
223
223
  x: 100,
224
- y: CY,
224
+ y: H / 2,
225
225
  }
226
226
 
227
227
  tween(pos, "x", 250, 2, BOUNCE_OUT).start()