Skip to content

Instantly share code, notes, and snippets.

@iconmaster
Last active October 27, 2017 12:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iconmaster/cbbf99171e648688e01568911553728c to your computer and use it in GitHub Desktop.
Save iconmaster/cbbf99171e648688e01568911553728c to your computer and use it in GitHub Desktop.
A simple Framer module for performing animation curve math
###
# Adapted from https://gist.github.com/gre/1650294
# USING THE CURVES MODULE
# Require the module
Curves = require "Curves"
# Translate a value between 0 and 1 into the "curved" value
print Curves.easeOutQuad(0.5)
###
exports.linear = (t) ->
t
exports.easeInQuad = (t) ->
t * t
exports.easeOutQuad = (t) ->
t * (2 - t)
exports.easeInOutQuad = (t) ->
if t < .5 then 2 * t * t else -1 + (4 - (2 * t)) * t
exports.easeInCubic= (t) ->
t * t * t
exports.easeOutCubic= (t) ->
--t * t * t + 1
exports.easeInOutCubic = (t) ->
if t < .5 then 4 * t * t * t else (t - 1) * (2 * t - 2) * (2 * t - 2) + 1
exports.easeInQuart= (t) ->
t * t * t * t
exports.easeOutQuart= (t) ->
1 - (--t * t * t * t)
exports.easeInOutQuart = (t) ->
if t < .5 then 8 * t * t * t * t else 1 - (8 * --t * t * t * t)
exports.easeInQuint= (t) ->
t * t * t * t * t
exports.easeOutQuint = (t) ->
1 + --t * t * t * t * t
exports.easeInOutQuint = (t) ->
if t < .5 then 16 * t * t * t * t * t else 1 + 16 * --t * t * t * t * t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment