Created
March 16, 2016 03:12
-
-
Save monsieuroeuf/749315d600737ee0e543 to your computer and use it in GitHub Desktop.
After Effects expression: automatic motion with expo easing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ian Haigh : http://ianhaigh.com/ | |
// automatic motion for After Effects with expo easing | |
// set up sliders to easily change the values | |
function easeandwizz_inExpo(t, b, c, d) { | |
var IN_EXPO_CORRECTION = 0.000976; | |
return t==0 ? b : c * (Math.pow(2, 10 * (t/d - 1)) - IN_EXPO_CORRECTION) + b; | |
} | |
function easeandwizz_outExpo(t, b, c, d) { | |
var OUT_EXPO_CORRECTION = 1.000976; | |
return (t==d) ? b+c : c * OUT_EXPO_CORRECTION * (-Math.pow(2, -10 * t/(d)) + 1) + b; | |
} | |
var slideDuration; | |
try { var inDistance = effect("inDistance")("Slider") } catch(e) { var inDistance = 1920 } | |
try { var outDistance = effect("outDistance")("Slider") } catch(e) { var outDistance = 1920 } | |
try { var slowSlideDistance = effect("slowSlideDistance")("Slider") } catch(e) { var slowSlideDistance = 0 } | |
try { | |
if (effect("flip direction")("Checkbox") == true) { | |
slowSlideDistance *= -1; | |
outDistance *= -1; | |
inDistance *= -1; | |
} | |
} catch(e) {} | |
try { | |
slideDuration = effect("slideDuration")("Slider"); | |
} catch(e) { | |
slideDuration = 0.5; | |
} | |
if ((time >= inPoint) && (time <= inPoint + slideDuration)) { | |
var normalisedTime = linear(time, inPoint, inPoint + slideDuration, 0, 1); | |
easeandwizz_outExpo(normalisedTime, value-inDistance, inDistance, 1); | |
} else if ((time > outPoint - slideDuration) && (time <= outPoint) ) { | |
var normalisedTime = linear(time, outPoint - slideDuration, outPoint, 0, 1); | |
easeandwizz_inExpo(normalisedTime, value + slowSlideDistance, outDistance, 1); | |
} else { | |
linear(time, inPoint + slideDuration, outPoint - slideDuration, value, value + slowSlideDistance); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment