ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

link skew and position in a shape layer

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Steve Sierra
link skew and position in a shape layer
on Aug 7, 2018 at 2:15:50 pm

Hello everyone,

I am trying to link skew and position between two rectangle paths in a shape layer. I would like for the second one to skew as it moves on the X axis in order for it's top right corner meets the top right corner of the first rectangle (making half of a rooftop).
I am trying to use Math.atan, but it only gives me small numbers between 1 and 1.5 more or less...
My rectangles both start at pos [0, 0] and the anchor points are at their center, so I divided the height by two.
Any help would be appreciated !
Thanks 😉

Here's my expression for the skew property :

a = content("Rectangle 1").content("Rectangle Path 1").size[1]/2;
b = content("Rectangle 2").content("Rectangle Path 1").position[0];
Math.atan(a/b)


Return to posts index

Kalleheikki Kannisto
Re: link skew and position in a shape layer
on Aug 7, 2018 at 2:35:37 pm

Despite several attempts to understand the objective I fail to do so. Can you do a manual mockup of what you want to happen when one of the shapes moves, two different positions?

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Steve Sierra
Re: link skew and position in a shape layer
on Aug 7, 2018 at 3:04:14 pm

Hi,

Sorry if I wasn't clear enough... Here are some pics to better explain. The first one is what I want, the other is what I get !

Thanks !




Return to posts index


Kalleheikki Kannisto
Re: link skew and position in a shape layer
on Aug 8, 2018 at 7:01:09 am

You weren't that far off. The main issue is that javascript uses radians instead of degrees, so you have to convert them to degrees (this is why you were getting figures in such a low range). Then switch a/b to b/a and reverse the slant angle with a minus and you'll be all set:

a = content("Rectangle 1").content("Rectangle Path 1").size[1]/2;
b = content("Rectangle 2").content("Rectangle Path 1").position[0];
s = -radiansToDegrees(Math.atan(b/a))


Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Steve Sierra
Re: link skew and position in a shape layer
on Aug 8, 2018 at 9:38:03 am

Hi Kalleheikki,

Thank you very much ! This works perfectly .
I had just found a workaround : I just offset the rectangle 2 Anchor point to its top/center. I then just have to change the skew amount 😉

Thanks again for your time.
Best regards,

S.


Return to posts index

Kalleheikki Kannisto
Re: link skew and position in a shape layer
on Aug 8, 2018 at 5:11:31 pm

Ok, great. Anchor points are handy that way.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

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