fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
3 lines (2 loc) • 920 B
JavaScript
import{Color as t}from"../../color/Color.min.mjs";import{halfPI as a}from"../../constants.min.mjs";import{capValue as e}from"../misc/capValue.min.mjs";import{AnimationBase as o}from"./AnimationBase.min.mjs";const s=(t,e,o,s)=>e+o*(1-Math.cos(t/s*a)),n=a=>a&&((e,o,s)=>a(new t(e).toRgba(),o,s));class r extends o{constructor(a){let{startValue:e,endValue:o,easing:r=s,onChange:m,onComplete:i,abort:l,...u}=a;const c=new t(e).getSource(),p=new t(o).getSource();super({...u,startValue:c,byValue:p.map((t,a)=>t-c[a]),easing:r,onChange:n(m),onComplete:n(i),abort:n(l)})}calculate(t){const[a,o,s,n]=this.startValue.map((a,e)=>this.easing(t,a,this.byValue[e],this.duration,e)),r=[...[a,o,s].map(Math.round),e(0,n,1)];return{value:r,valueProgress:r.map((t,a)=>0!==this.byValue[a]?Math.abs((t-this.startValue[a])/this.byValue[a]):0).find(t=>0!==t)||0}}}export{r as ColorAnimation};
//# sourceMappingURL=ColorAnimation.min.mjs.map