Copy link to clipboard
Copied
i'm trying to have Words highlight with an effect applied to a solid, which is assigned to the text layer, as they are spoken in a paragraph. i'm was planning to be using markers to trigger when each Word is said with this: https://www.youtube.com/watch?v=diaCkKp5lpY
Something kind of close was discussed here:
https://community.adobe.com/t5/after-effects-discussions/text-range-selector-position-value-expressi...
but i'm working with a weird way of highlighting text with an expression selector and i think the text box remains the same width (sourceRectAtTime()).
This is a better version that creates a tiny, off-screen mask when there's no text layer to proces (so the mask layer doesn't show up) and corrects a logic error:
pad = 10;
c = thisComp.layer("Scripture");
m = c.marker;
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
if (n > 0 && n < index - c.index){
L = thisComp.layer(c.index + n);
r = L.sourceRectAtTime(time,false);
ul = L.toComp([r.left,r.top]);
ur = L.toComp([r.left+r.width,r.top]);
lr = L.toComp([r.left+r.width,r.top
...
Copy link to clipboard
Copied
it works if i use your original code to manually update every text layer
L = thisComp.layer("Text " + n);
so if there isn't a way to deal with anonomous incremental layers ...i could just get a renamer plugin like this one:
https://aescripts.com/ae-global-renamer/
Copy link to clipboard
Copied
OK, how about this. The expression will limit itself to layers that if finds between the "Scripture" marker layer and the layer that has the expression. So you'd have marker layer, text layers, then expression layer. The expression would look like this:
pad = 10;
c = thisComp.layer("Scripture");
m = c.marker;
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
if (n > 0 && n < index){
L = thisComp.layer(c.index + n);
r = L.sourceRectAtTime(time,false);
ul = L.toComp([r.left,r.top]);
ur = L.toComp([r.left+r.width,r.top]);
lr = L.toComp([r.left+r.width,r.top+r.height]);
ll = L.toComp([r.left,r.top+r.height]);
p = [fromComp(ul)+[-pad,-pad], fromComp(ur)+[pad,-pad], fromComp(lr)+[pad,pad], fromComp(ll)+[-pad,pad]];
createPath(p,[],[],true);
}else
value
Copy link to clipboard
Copied
This is a better version that creates a tiny, off-screen mask when there's no text layer to proces (so the mask layer doesn't show up) and corrects a logic error:
pad = 10;
c = thisComp.layer("Scripture");
m = c.marker;
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
if (n > 0 && n < index - c.index){
L = thisComp.layer(c.index + n);
r = L.sourceRectAtTime(time,false);
ul = L.toComp([r.left,r.top]);
ur = L.toComp([r.left+r.width,r.top]);
lr = L.toComp([r.left+r.width,r.top+r.height]);
ll = L.toComp([r.left,r.top+r.height]);
p = [fromComp(ul)+[-pad,-pad], fromComp(ur)+[pad,-pad], fromComp(lr)+[pad,pad], fromComp(ll)+[-pad,pad]];
}else{
p = [[-10,-10],[-9,-10],[-9,-9],[-10,-9]];
}
createPath(p,[],[],true);