Type & Text

Recommended Readings

Item

Links

Documentation / Tutorials

​

Industry / Case-studies

  • ​

Books

  • ​

Papers

​

  • ​

Binary Generator

n = 300; // connect to slider
seedRandom(seed,true);
let m = b = '';
for(i=0;i<n;i++){
seedRandom(i+seed,true);
b = Math.round(random(1)).toString()
m +=b;
}

Counter

Math.floor(time*10);
​
// with decimals
....

Text repeater

normal
vertical
normal
n = 8; // connect to a slider
s = myText = value ;
for(i=1; i<n; i++) s += myText; s;
vertical
n = 8; // connect to a slider
s = myText = value ;
for(i=1; i<n; i++) s += "\r" + myText; s;

Separating source text line feeds into an array

// Basic
txt = thisComp.layer("insert Text").text.sourceText;
txt.split("\r")[3]; // Regex
​
// using name as index
txt = thisComp.layer("insert Text").text.sourceText;
myIndex = thisLayer.name;
txt.split("\r")[myIndex]

Matching text

//REGEX
thisComp.layer("text").text.sourceText.toLowerCase().match(/\w+\./))

Numbers

Rounding numbers to decimals

x = time;
pow = Math.pow(10,5) // 5 is the number of decimals
x = Math.round(x*pow)/pow;

​

Expressions selector

Default

selectorValue * textIndex/textTotal

%

if(textIndex%2) 0 else 100

​Random position from textIndex

seedRandom(textIndex,true);
random([100,100]);
​
​

Select text indexes explicitly; e.g. 1, 3, 7, 14, 22, etc.?

If you don't have a lot of numbers, then this works:
​
if(textIndex === 1 || textIndex ===3) {
100;
} else {
0;
}
​
If you do have a ton of numbers, then this works:
​
i = [1,3,5,7,10,11];
inArray(i);
​
function inArray(obj) {
b = 0;
for(i = 0; i < obj.length; i++) {
if(obj[i] === textIndex) {
b = 100;
break;
}
}
return b;
}
​
​

Expression Selector (Regex)

https://forums.creativecow.net/thread/227/41461
Oleg Pirogov
https://dribbble.com/zeplin
​
var t = text.sourceText;
var regex = /\d[a-z]+(?=,)/g;
​
function indexMatched(index){
var matched = false;
var match;
var i=[];
​
while ((match = regex.exec(t)) !== null){
matched |= match.index<index & index<match.index+match[0].length;
i.push([match, match.index, match.index+match[0].length]);
}
return matched;
}
​
indexMatched(textIndex-1) ? 100 : 0;

var t = text.sourceText;
var regex = /\(([^)]+)(?=\))/g;
​
function indexMatched(index){
var matched = false;
var match;
​
while ((match = regex.exec(t)) !== null){
matched |= match.index<index & index<match.index+match[0].length;
}
return matched;
}
​
indexMatched(textIndex-1) ? 100 : 0;
​

Hexcode

var t = text.sourceText;
var regex = /[A-Fa-f0-9]{6}/g;
​
function indexMatched(index){
var matched = false;
var match;
​
while ((match = regex.exec(t)) !== null){
matched |= match.index<index & index<=match.index+match[0].length;
}
return matched;
}
​
indexMatched(textIndex) ? 100 : 0;