ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Position of shape layer elements

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jonas Karten
Position of shape layer elements
on May 8, 2019 at 3:54:00 pm

Hi there!

I have a grid with 120 circles (within a single shape layer) which I want to animate through another layer.

The circles are supposed to check which color is on their exact position on this second layer and change their size accordingly. Black will shrink them to 0%, gray shrinks them to 50% and white will leave them at 100% of their size.

This works not like I want since all individual circles use the same reference point, the position of the layer and not the single element.

Question: How can I change

"samplePoint = transform.position;"

to a behaviour like

"samplePoint = content("Circle_123").transform.position;"

without using absolute names like "Circle_123" but something more universal like "this.Element" or "this.Content"?

Or would it be easier if I just place every circle on a different layer with the shape centered on this layer? Until now, I tried to keep the the circles in a single shape layer to have a better overview and be able to change the properties more easily.

sourceLayer = comp("Grid").layer("Gradient");
sampleSize = [1,1];
samplePoint = transform.position;
color= sourceLayer.sampleImage(samplePoint,sampleSize);
x=color[0]*100;
[x,x]


Return to posts index

Dan Ebberts
Re: Position of shape layer elements
on May 8, 2019 at 4:39:24 pm

Assuming that the Gradient layer is comp-sized and you're applying the expression to the Size property, something like this should be close:

sourceLayer = comp("Grid").layer("Gradient");
sampleSize = [1,1];
samplePoint = toComp(thisProperty.propertyGroup(3)("Transform")("Position"));
color= sourceLayer.sampleImage(samplePoint,sampleSize);
x=color[0]*100;
[x,x]


Dan



Return to posts index

Jonas Karten
Re: Position of shape layer elements
on May 9, 2019 at 9:44:43 am

Thank you very much Dan, this is what I needed. Didn't know about the propertyGroup yet! Great!

With the help of your code I've applied it to the scale within the "transform: Circle 123" tab of the individual circle:

sourceLayer = comp("Raster").layer("Verlauf");
sampleSize = [1,1];
samplePoint = toComp(thisProperty.propertyGroup(2)("Transform")("Position"));
color= sourceLayer.sampleImage(samplePoint,sampleSize);
x=color[0]*100;
[x,x]

I understand that propertyGroup(2) looks up the value of the second element within the group/transform-tab, which is the position, right? Like this I can still use the percentages and a starting size of the circle.


Return to posts index


Dan Ebberts
Re: Position of shape layer elements
on May 9, 2019 at 11:59:52 am

propertyGroup(2) moves up two levels in the hierarchy from the property hosting the expression. It gets a little tricky with shape layers because not all the property levels are visible in AE's UI.


Dan



Return to posts index

Filip Vandueren
Re: Position of shape layer elements
on May 9, 2019 at 6:57:28 pm

True,

this script is a godsend to try and comprehend how properties are nested into each other:

http://www.redefinery.com/ae/view.php?item=rd_GimmePropPath



Return to posts index

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