Skip to content

Instantly share code, notes, and snippets.

@fallenleavesguy
Last active January 23, 2018 01:04
Show Gist options
  • Save fallenleavesguy/1d0ee26a7afa437c8fe568889d38ba7a to your computer and use it in GitHub Desktop.
Save fallenleavesguy/1d0ee26a7afa437c8fe568889d38ba7a to your computer and use it in GitHub Desktop.
ellipse interpolation
export function ellipseInterpolation(x, y, radiusX, radiusY, startProgress = 0, clockwise = true) {
const dir = ( clockwise ? 1 : -1);
return function (t) {
t = (t + startProgress);
const radian = t * Math.PI * dir * 2;
return {
x: radiusX * Math.cos(radian) + x,
y: radiusY * Math.sin(radian) + y
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment