-
Auto Scaling Expression for layers with wiggle
I’ve been straining my brain trying to come up with a solution to auto-scale a layer after a wiggle has been applied to the position and rotation properties. So that as a layer wiggles around, it will automatically scale up and down to fill up the edges of the frame that its moving away from. Similar to how the Warp Stabilizer will auto scale when reducing motion.. but I’m looking to auto-scale when ADDING motion.
I’ve been able to hack something together only if the position wiggles, but when I add rotation I just can’t seem to find a common ratio that it needs to scale by. The trigonometry goes a little above my head on this one.
My position auto-scale expression works like this. It’s probably not the best way to do it, but its the way my brain could understand things! If you have a better way please let me know!
compHeight=thisComp.height/2;
compWidth=thisComp.width/2;
layerX=transform.position[0];
layerY=transform.position[1];
xDistance=Math.abs(compWidth-layerX);
yDistance=Math.abs(compHeight-layerY);
xDistPercentage=xDistance/compWidth*100;
yDistPercentage=yDistance/compHeight*100;
autoScale=null;if(xDistPercentage > yDistPercentage){
if(layerX < compWidth){
layerX=layerX+(xDistance*2)
}autoScale=value/compWidth*layerX
}else{
if(layerY < compHeight){
layerY=layerY+(yDistance*2)
}autoScale=value/compHeight*layerY
}autoScale
Which will automatically scale the layer up like this if the layer is moved from center:

However whenever rotation is applied, it fails hard:
Does anyone know of any magic to help this out? Is there a way to determine how much the layer needs to additionally scale by based on how much rotation is applied?
Please help!!
Cheers,
Philip Bowser
