UNPKG

fabric

Version:

Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.

2 lines 913 B
import{halfPI as e}from"../../constants.min.mjs";import{Color as t}from"../../color/Color.min.mjs";import{capValue as n}from"../misc/capValue.min.mjs";import{AnimationBase as r}from"./AnimationBase.min.mjs";const i=(t,n,r,i)=>n+r*(1-Math.cos(t/i*e)),a=e=>e&&((n,r,i)=>e(new t(n).toRgba(),r,i));var o=class extends r{constructor({startValue:e,endValue:n,easing:r=i,onChange:o,onComplete:s,abort:c,...l}){let u=new t(e).getSource(),d=new t(n).getSource();super({...l,startValue:u,byValue:d.map((e,t)=>e-u[t]),easing:r,onChange:a(o),onComplete:a(s),abort:a(c)})}calculate(e){let[t,r,i,a]=this.startValue.map((t,n)=>this.easing(e,t,this.byValue[n],this.duration,n)),o=[...[t,r,i].map(Math.round),n(0,a,1)];return{value:o,valueProgress:o.map((e,t)=>this.byValue[t]===0?0:Math.abs((e-this.startValue[t])/this.byValue[t])).find(e=>e!==0)||0}}};export{o as ColorAnimation}; //# sourceMappingURL=ColorAnimation.min.mjs.map