ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Use sampleImage() on a Text Animation Expression Selector

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Nawaz Alamgir
Use sampleImage() on a Text Animation Expression Selector
on Jun 28, 2020 at 2:26:47 pm

Is it possible to use a sampleImage() expression on a Text Animation Expression Selector?

I want my Gradient layer to affect the size of a text layer using the code below.

its it possible?

x = thisComp.layer("Gradient").sampleImage(transform.position, [.5,.5]/2, true, time)[0];
100*[x,x]


Return to posts index

Filip Vandueren
Re: Use sampleImage() on a Text Animation Expression Selector
on Jun 29, 2020 at 11:24:14 am

It works for me.
What's happening for you ?

Maybe your text is parented and then the position-value doesn't correspond exactly with the position of the gradient.



Return to posts index

Nawaz Alamgir
Re: Use sampleImage() on a Text Animation Expression Selector
on Jun 29, 2020 at 11:52:42 am

I've made a AE project, 2 comps, one works correct with 100 shape layers

but i want to use a block of "." characters that has its scale affected by the gradient map

https://www.dropbox.com/s/t7qlnmund1r6285/gradienteffectortest%2815.x%29.ae...


Return to posts index


Filip Vandueren
Re: Use sampleImage() on a Text Animation Expression Selector
on Jun 29, 2020 at 12:21:03 pm

So you want every character to respond to the gradient separately ?
Right now every point is looking at the position of the layer, not the position of the character.
There's no easy way to get that information, especially for actual text.

in your case, it is a perfect grid though, so you might get away with finding out and then hardcoding the distance between each dot ?
sourceRectAtTime() doesn't seem to work inside of the expression Selector, so I don't know an easy way to automate it.

Also makes sure that there are no extra spaces or line-breaks in the text, that would trip up the % calculation of the rows/columns

dots_cols = 26;

dot_pitch_h=24;
dot_pitch_v=42;

x = textIndex%dots_cols;
y = Math.floor(textIndex/dots_cols);

v = thisComp.layer("Gradient").sampleImage(transform.position + [x*dot_pitch_h, y*dot_pitch_v], [5,5], true, time)[0];

100*[v,v];




Return to posts index

Nawaz Alamgir
Re: Use sampleImage() on a Text Animation Expression Selector
on Jun 29, 2020 at 5:40:00 pm

Thanks for this, not sure how it works but its enough for me to get me started.


Return to posts index

Filip Vandueren
Re: Use sampleImage() on a Text Animation Expression Selector
on Jun 29, 2020 at 7:21:34 pm

the built-in "textIndex" value, is a different value for every character in your text.
This lets us calculate different amounts for different characters via an expression-selector.

However .position is still just the position of the layer, not different for each character.

In your case where the characters form a perfect grid, we can use that textIndex-value to calculate the grid-positions.
Using % and Math.floor is a tried and tested method for getting positions in a grid if you know how many columns there are.
The grid then gets multiplied by value that represents how far apart the dots are (dot-pitch); this is dependent on your font, it's leading and tracking,… and you'll have to figure that one out on your own, because we can't calculate that with expressions, at least not from within this Expression-Selector, which sometimes acts as a special case as to what you can and can't access.

good luck



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]