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

{Feature request] Animating a vector #906

Open
matthiasferch opened this issue Feb 23, 2021 · 1 comment
Open

{Feature request] Animating a vector #906

matthiasferch opened this issue Feb 23, 2021 · 1 comment

Comments

@matthiasferch
Copy link

matthiasferch commented Feb 23, 2021

I would like to be able to animate a 2D vector, like so:

interface vector {
  x: number,
  y: number;
}

const from = { x: 0.0, y: 0.0 };
const to = { x: 4.0, y: 2.0 };

animate<vector>({ from, to, onUpdate: (vector) => console.log(vector) });

I would like to try adding support for this myself but I'm not sure where to start. Could you point me in the right direction?

@stokesman
Copy link
Contributor

Perhaps you've already figured this out. In case it could help anyone, the included interpolate function can be used for that.

const fromTo = interpolate(
  [0, 1],
  [
    { x: 0.0, y: 0.0 },
    { x: 4.0, y: 2.0 }
  ]
)
animate({ onUpdate: v => console.log(fromTo(v)) });

I guess you could create an animate wrapper that automates it 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

No branches or pull requests

2 participants