Hi Tom, I’m very new to expressions so I’m still trying to learn what I can about them while actively practicing. I actually got pretty close by using GPT to help.
I set the anchor point of the pink shape to the bottom right corner and the grey shape to the top left corner and then added expressions to the position properties of each shape.
For the pink shape I added this expression:
var blackBox = thisComp.layer(“Black Box”);
var blackBoxPosition = blackBox.transform.position;
var blackBoxScale = blackBox.transform.scale[0] / 100;
var xOffset = (blackBox.width / 2 * blackBoxScale) + (thisLayer.width / 2 * blackBoxScale);
var yOffset = (blackBox.height / 2 * blackBoxScale) + (thisLayer.height / 2 * blackBoxScale);
[blackBoxPosition[0] – xOffset, blackBoxPosition[1] – yOffset];
And for the grey, this one:
var blackBox = thisComp.layer(“Black Box”);
var blackBoxPosition = blackBox.transform.position;
var blackBoxScale = blackBox.transform.scale[0] / 100;
var xOffset = (blackBox.width / 2 * blackBoxScale) + (thisLayer.width / 2 * blackBoxScale);
var yOffset = (blackBox.height / 2 * blackBoxScale) + (thisLayer.height / 2 * blackBoxScale);
[blackBoxPosition[0] + xOffset, blackBoxPosition[1] + yOffset];