Open tony-schumacher opened 2 years ago
Should we return an error in such a scenario? And maybe recommend a library such as https://github.com/notoriousb1t/polymorph to prepare the paths? Let me know your thoughts on this.
Hey @wcandillon,
I will check this out. An error makes sense if having the same data length is a requirement. If not a I would expect the method to handle it.
Another solution would be something likes this which results in a better animation:
const p1a = {
...p2,
curves: p2.curves.map((_curve) => {
const c = JSON.parse(JSON.stringify(_curve));
c.c1.x = 0;
c.c2.x = 0;
c.to.x = 0;
c.c1.y = maxY;
c.c2.y = maxY;
c.to.y = maxY;
return c;
}),
};
return interpolatePath(value, [0, 1], [p1a, p2]);
If having the same path length is a requirement we could at least note this in the documentation? Failing that, I would +1 this change!
I forked the library and used the change already. Works for me, even though the animation looks better if the length is the same. Might handle this with a functions which reduces all arrays to the same length.
I forked the library and used the change already. Works for me, even though the animation looks better if the length is the same. Might handle this with a functions which reduces all arrays to the same length.
I tried to install your fork but yarn/npm are not actually building the lib/modules, only installing the typescript src. Is there a way I could use your fork? I can't figure it out. Thanks!
@TonySchu I'm confused on what this change does exactly, can you walk me through me? Maybe provide me with two paths to interpolate as a test? you can add interpolate path test cases too.
Mixpath was crashing when the length of the curve arrays were different. This PR fixes it by using mixing the previous Path with the new one.