Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save matthewsimo/37044f03bd48645de7ef02d33e2327f4 to your computer and use it in GitHub Desktop.
Save matthewsimo/37044f03bd48645de7ef02d33e2327f4 to your computer and use it in GitHub Desktop.
Reverse a two-point cubic bezier
/* sample cubic beziers */
linear = [0.250, 0.250, 0.750, 0.750];
ease = [0.250, 0.100, 0.250, 1.000];
easeIn = [0.420, 0.000, 1.000, 1.000];
easeOut = [0.000, 0.000, 0.580, 1.000];
easeInOut = [0.420, 0.000, 0.580, 1.000];
function reverseCubicBezier(cubicBezier) {
return [
1 - cubicBezier[2],
1 - cubicBezier[3],
1 - cubicBezier[0],
1 - cubicBezier[1]
];
}
console.log(reverseCubicBezier(linear));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment