Activity › Forums › Adobe After Effects Expressions › Use sampleImage() on a Text Animation Expression Selector
-
Use sampleImage() on a Text Animation Expression Selector
Posted by Nawaz Alamgir on June 28, 2020 at 2:26 pmIs 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]Filip Vandueren replied 5 years, 10 months ago 2 Members · 5 Replies -
5 Replies
-
Filip Vandueren
June 29, 2020 at 11:24 amIt 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.
-
Nawaz Alamgir
June 29, 2020 at 11:52 amI’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.aep?dl=0
-
Filip Vandueren
June 29, 2020 at 12:21 pmSo 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];
-
Nawaz Alamgir
June 29, 2020 at 5:40 pmThanks for this, not sure how it works but its enough for me to get me started.
-
Filip Vandueren
June 29, 2020 at 7:21 pmthe 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
Reply to this Discussion! Login or Sign Up