Last active
January 15, 2021 05:12
-
-
Save nariakiiwatani/336daf51dafa8cfa53cd73649d79589e to your computer and use it in GitHub Desktop.
AfterEffects Expression Utils
This file contains 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
// demo: https://twitter.com/nariakiiwatani/status/1280689913202016256 | |
const fadeIn = 0.2, fadeOut = 0.4, | |
lerp = (x, x0, x1, y0, y1) => (y0 + (y1 - y0) * (x - x0) / (x1 - x0)), | |
off = 0, | |
on = 1, | |
calcAlpha = (time, from, to, fadeIn, fadeOut) => (clamp(Math.min(lerp(time, from, from+fadeIn, off, on), lerp(time, to-fadeOut, to, on, off)),off,on)); | |
([...Array(marker.numKeys).keys()] | |
.map(i=>marker.key(i+1)) | |
.reduce((acc, m) => acc+calcAlpha(time, m.time, m.time+m.duration, fadeIn, fadeOut), 0)) | |
*100 |
This file contains 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
// demo: https://twitter.com/nariakiiwatani/status/1280358237246636032 | |
[...Array(marker.numKeys).keys()] | |
.map(i=>marker.key(i+1)) | |
.filter(m=>timeToFrames(m.time) <= timeToFrames(time) && timeToFrames(time) < timeToFrames(m.time+m.duration)) | |
.map(m=>m.comment).join("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment