Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle different length on mixpath #482

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tony-schumacher
Copy link

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.

@wcandillon
Copy link
Owner

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.

@tony-schumacher
Copy link
Author

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]);

@ksinghj
Copy link

ksinghj commented Mar 21, 2022

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!

@tony-schumacher
Copy link
Author

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.

@BernardoQuina
Copy link

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!

@wcandillon
Copy link
Owner

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants