ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

One shape adjusting to match max value of another shape

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Vince Babbra
One shape adjusting to match max value of another shape
on Jan 24, 2018 at 8:02:51 pm

I am a complete noob at expressions so any help greatly appreciated!

I have 2 rectangle shapes. Rectangle 1 describes a path through movement of its y-position, with keyframes that have values of (example) 100, 300, 200, 400, 250, 600, 700, 400, 750 etc... so it is describing a generally upward movement but with dips backwards. Rectangle 2 shape y-axis scale is currently linked via a linear function to extend from its origin so that rectangle 2's y-scale corresponds to the y-position of rectangle 1's. In this way, the edge of rectangle 2 is locked to rectangle 1.

I have done this as follows

Expression on Scale on RECTANGLE 2

t = thisComp.layer("RECTANGLE 1").transform.yPosition;
x = linear(t, 30, 800, 50, 2);
[2.5,x]

This works perfectly. My problem is I need the scale of Rectangle 2 to track the position of Rectangle 1's maximum value up till that point, not it's current value. So as Rectangle 1 reaches a new high and dips backward, Rectangle 2 stays at a length that corresponds to Rectangle 1's highest value till that point in the composition. This is almost like the 'peak hold' function on a graphic equaliser. Every time a new peak is achieved, the scale holds that peak.

I don't know how to do this... Please help.

t = thisComp.layer("RECTANGLE 1").transform.yPosition;
x = linear(t, 30, 800, 50, 2);
[2.5,x]


Return to posts index

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