Created
March 12, 2021 09:47
-
-
Save Jimmyson/e7d5acb85674fc0c4d13e14dd60c4b0b to your computer and use it in GitHub Desktop.
BBC News - Text Decode animation expression
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
//READS INPUTED TEXT | |
var string = text.sourceText; | |
var lng_size = string.length; | |
var lng_char = string.split(""); | |
//DROPS SPACES | |
var srt_string = string.replace(/ /gi,""); | |
var srt_size = srt_string.length; | |
var srt_char = srt_string.split(""); | |
//ANIMATION SETUP | |
var word_loop = 1; //Times animation is looped | |
var pause = 7; //Frames the animation is paused for | |
var loop_length = srt_size*word_loop; | |
var ani_length = loop_length+pause; | |
var reverse = false; | |
var layerTime = timeToFrames(time-inPoint); | |
var output = ""; | |
var loopFrame = layerTime%ani_length; | |
if (loopFrame >= loop_length) { | |
var offset = 0; | |
} else if (reverse == true) { | |
var offset = (1+loopFrame)%srt_size; | |
} else { | |
var offset = srt_size-(1+loopFrame)%srt_size; | |
} | |
for (i = 0; i < lng_size; i++) { | |
if (lng_char[i] == " ") { | |
output += " "; | |
} else { | |
output += srt_char[Math.abs(offset%srt_size)]; | |
offset++; | |
} | |
} | |
output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment