-
Expression to make one shape mimic another’s scale & position?
Okay so I make templates to be used in after effects through the use of Dataclay so one of the big factors in what I do is making sure things stay uniform as information and values within the projects are adjusted before exporting. The desired animation I am creating is illustrated in the gif below, now my dilemma arises when I try to get the coloured boxes to adjust scale and position along with their black foreground counterparts.
Here is what I am currently working with in terms of expressions-
To adjust black box size:
The first expression needs to be applied to the shape layers position:t = thisComp.layer(“my_text”);
tRect = t.sourceRectAtTime(time,false);
tUL = t.toComp([tRect.left,tRect.top]);
tLR = t.toComp([tRect.left+tRect.width,tRect.top+tRect.height]);
tCenter = (tUL + tLR)/2
myRect = sourceRectAtTime(time,false);
myUL = toComp([myRect.left,myRect.top]);
myLR = toComp([myRect.left+myRect.width,myRect.top+myRect.height]);
myCenter = (myUL + myLR)/2
delta = myCenter – tCenter;
value – deltaThis expression needs to be applied to the shapes scale within the shape itself’s transform options for scale. Rectangle 1 > Rectangle 1 Path > Size. In my first test I also applied this expression to the shape layers scale:
t = thisComp.layer(“my_text”);
tRect = t.sourceRectAtTime(time,false);
tUL = t.toComp([tRect.left,tRect.top]);
tLR = t.toComp([tRect.left+tRect.width,tRect.top+tRect.height]);
myRect = sourceRectAtTime(time,false);
myUL = toComp([myRect.left,myRect.top]);
myLR = toComp([myRect.left+myRect.width,myRect.top+myRect.height]);
margin = 10;
[(tLR[0]-tUL[0] + 2*margin)/(myLR[0]-myUL[0]),(tLR[1]-tUL[1]+ 2*margin)/(myLR[1]-myUL[1])]*100And my expression to control the coloured boxes behind which are referencing an adjustment layer with Slider Control. They have both the size adjustment expressions as well as this expression:
wiggle(10, thisComp.layer(“Slider 1”).effect(“Slider Control”)(“Slider”))I’ve been using after effects professionally since March of 2017 and largely learnt much of this from this site. It is my first time posting so please let me know if I have left out any necessary information. I should also note that the actual desired template only has single lines of text.
t = thisComp.layer("my_text");
tRect = t.sourceRectAtTime(time,false);
tUL = t.toComp([tRect.left,tRect.top]);
tLR = t.toComp([tRect.left+tRect.width,tRect.top+tRect.height]);
tCenter = (tUL + tLR)/2
myRect = sourceRectAtTime(time,false);
myUL = toComp([myRect.left,myRect.top]);
myLR = toComp([myRect.left+myRect.width,myRect.top+myRect.height]);
myCenter = (myUL + myLR)/2
delta = myCenter - tCenter;
value - delta
wiggle(10, thisComp.layer("Slider 1").effect("Slider Control")("Slider"))
