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

Chain easing from vector #36

Open
soanvig opened this issue May 8, 2024 · 0 comments
Open

Chain easing from vector #36

soanvig opened this issue May 8, 2024 · 0 comments

Comments

@soanvig
Copy link

soanvig commented May 8, 2024

Hey! I would like to start with BIG THANKS for creating a library that is great of use to me as a Bevy newbie.

I have dynamically generated vector of animations to perform (interpolated movement on the grid).
It is almost impossible (more on that later) to convert that vector to chain of animations.

Normally one would use fold: vector.iter().fold(component, |component, animation| component.ease_to(animation)
but it doesn't work, because types change:

component -> Component
component.ease_to() -> EasingComponent<Component>
component.ease_to().ease_to() -> EasingChainComponent<Component>
component.ease_to().ease_to().ease_to() -> EasingChainComponent<Component>

The best workaround I found is to call .ease_to two times to stabilize type into EasingChainComponent, and then fold normally:

let animation_component = component
            .ease_to(
                component.clone(),
                EaseMethod::Linear,
                EasingType::Once {
                    duration: std::time::Duration::from_millis(0),
                },
            )
            .ease_to(
                component.clone(),
                EaseMethod::Linear,
                EasingType::Once {
                    duration: std::time::Duration::from_millis(0),
                },
            );

        let animation_component =
            interpolation
                .iter()
                .fold(animation_component, |component, interpolation_item| {
                    component.ease_to(
                        <actual easing using interpolation_item>
                    )
                });

I think it would be interesting to have some way to approach that in non-hacky way. I'm newbie, so I really cannot suggest anything unfortunately.

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

No branches or pull requests

1 participant