- April 5, 2021 at 2:08 pm
Is there an easy way of calculating the scaling of a layer in order to fit the composition size, even if that layer is rotated? So something similar to the photoshop crop tool, where as you rotate the layer, it scales to fit the canvas.
Lets say I have a 1920×1080 comp and a layer the same size, with the anchor point in the middle. When I rotate the layer 10 degrees, I can see the layer cannot fit the comp anymore.
Is there an expression I can add the the scale property of the layer so that it fits automatically the composition?
- April 5, 2021 at 4:19 pm
Something like this maybe:
a = degreesToRadians(rotation);
s = Math.abs(Math.sin(a));
c = Math.abs(Math.cos(a));
w = width*c + height*s;
h = width*s + height*c;
- April 5, 2021 at 4:32 pm
Thank you a lot for your answer.
Modifying the last line from [100,100]/Math… to [100,100]*Math… does exactly what I want.
Do you happen to have any link so I can read about this calculation to understand it a bit better?
- April 5, 2021 at 5:53 pm
I am on board with Aris here, Dan. This would be great for one of your motionscript.com explanations with notes on the expression!
Such a simple and elegant solution!!!
Log in to reply.