ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Moving anchor point when rectangle is resized

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mervin James
Moving anchor point when rectangle is resized
on Nov 4, 2019 at 5:08:36 am

So im trying to create a tooltip with some controls for a project. I have a rectangle which I have repositioned the anchor point to the bottom of it. So the basic animation would just be two keyframes on the scale property 0 - 100. So obviously it scales from the anchor point... But if that rectangle is resized the animation will not look the same. What I would like to have is that when ever the rectangle is resized the anchor point will always move with it instead of staying in the same position so the animation doesnt get ruined. Essentially I would like the rectangle to resize from the center if possible. I hope im clear enough. Screenshot below. Thanks in advance for any help.



Return to posts index

Julien Schickel
Re: Moving anchor point when rectangle is resized
on Nov 4, 2019 at 1:20:08 pm

You got two options at least, I guess:

1-you can play with the scale of your rectangle (in Contents/"your form"/transform) which has its own anchor point that is different from the layer transform menu.

2- You can add a Null layer, place it on the center of your rectangle, parent your rectangle to the Null. Then, scaling the Null will scale your rectangle from its center, without changing neither its anchor point nor your animation.

Julien Schickel
Editor & motion designer
https://www.youtube.com/channel/UC7_NVR3JLdhEYDlEQuNFfug


Return to posts index

Mervin James
Re: Moving anchor point when rectangle is resized
on Nov 4, 2019 at 10:40:42 pm

Thanks for your replay Julian. I did try both ways and still isnt exactly what Im looking for. The first one the anchor point remains still which as a result the shape goes over it. Screenshot below. With your second solution the rectangle is being resized by the scale instead of the "size".


Screenshot of Anchor Point position botton Centre




After Scaling





So I would like to go from this




To this (Anchor point needs to move with the size (in this case the height) of the rectangle.



Thanks and sorry about the images I just find it can be easier to explain with visuals.


Return to posts index


Julien Schickel
Re: Moving anchor point when rectangle is resized
on Nov 5, 2019 at 9:01:34 am

This is more constraining, but I think here is a solution:

Paste these expressions:

On the layer anchorPoint:
R=sourceRectAtTime();
[R.left+R.width/2,R.top+R.height]

On the layer position:
value+transform.anchorPoint

I think it will give you the behaviour you're looking for.

I made two mini tutorials on this expression here, just in case:











Julien Schickel
Editor & motion designer
https://www.youtube.com/channel/UC7_NVR3JLdhEYDlEQuNFfug


Return to posts index

Mervin James
Re: Moving anchor point when rectangle is resized
on Nov 6, 2019 at 1:14:34 am
Last Edited By Mervin James on Nov 6, 2019 at 1:35:37 am

Thanks alot Julien it worked nicely and I could have really used those videos a few months ago so I will be checking out ya channel to see what other good stuff u got on there... Ne ways only other thing Id like to know is... If I want to reposition the anchor point say to a few other positions on the rectangle how would I do that e.g

I used this to get it to the center right side:
R = sourceRectAtTime();
[R.left+R.width,R.top+R.height/2];

and this to kind of offset it using a slider (dunno if thats the best way to do it but it works)
R = sourceRectAtTime();
S = thisComp.layer("Control").effect("Slider Control")("Slider");
[R.left+R.width,R.top+R.height/2]+S;

I'd like to know how to do it for the center left side and top of the rectangle please and thanks again.


Return to posts index

Julien Schickel
Re: Moving anchor point when rectangle is resized
on Nov 6, 2019 at 9:13:13 am

For the center left side:
R = sourceRectAtTime();
[R.left,R.top+R.height/2];

For the top center:
R = sourceRectAtTime();
[R.left+R.width/2,R.top];

Also, more than a slider, you can use a point control, this way, you'll have separate control of the X and Y offset (with the same expression that you use with the slider)

Thank you for the kind words!

Julien Schickel
Editor & motion designer
https://www.youtube.com/channel/UC7_NVR3JLdhEYDlEQuNFfug


Return to posts index


Mervin James
Re: Moving anchor point when rectangle is resized
on Nov 7, 2019 at 12:28:40 am

No problem I'm greatful for your help also. It's all working now except for when I place the anchor point on the left or right using the codes from above, it will only follow the rectangle's Width but will remain stable if the Height is changed. I'm guessing it has something to do with the value+transform.anchorPoint? Anyway to fix it so it follows the height also?


Return to posts index

Julien Schickel
Re: Moving anchor point when rectangle is resized
on Nov 8, 2019 at 11:14:09 am

No, trying it at home, it follows the width and the height. I'm guessing it has something to do with the slider you add, which doesn't change its value when the height or width changes.

For example, if you're using the expression above:
R = sourceRectAtTime();
[R.left,R.top+R.height/2];

placing the anchorPoint at the left in width and center in height, and you want to offset it to the lower quarter with a point control in height. If height is 1000, your height's point control will be 250, but if your rectangle height is 100, it should be 25.

So when adding a point control, in these cases, you should add to it the expression:
S=content(1).content(1).size;
[value[0]*S[0]/100,value[1]*S[1]/100]

That will in effect change the value of your point control proportionnally to the width & height changes.

Julien Schickel
Editor & motion designer
https://www.youtube.com/channel/UC7_NVR3JLdhEYDlEQuNFfug


Return to posts index

Mervin James
Re: Moving anchor point when rectangle is resized
on Nov 9, 2019 at 1:59:15 am
Last Edited By Mervin James on Nov 9, 2019 at 2:10:03 am

I'm actually looking to use slider controls because I've found that point control don't work well with the Essential Graphics Panel and thats here Im heading with this project. Though I tried it with the point control but I'm getting some weird results. [Im such a beginner with expression so please bare with me]... What I did was I placed a point control on my rectangle layer and pasted the code you gave me onto it. The dimensions of my rectangle is 1480x300 so I ended up with this

S=content(1).content(1).size;
[value[0]*S[0]/1480,value[1]*S[1]/300]

then on the anchor point of the rectangle I added

R = sourceRectAtTime();
S = effect("Point Control")("Point")[0];
L = effect("Point Control")("Point")[1];
[R.left-S,R.top+R.height/2+L];

and on the positon
value+transform.anchorPoint

Just to illustrate what Im trying to do also...




After height is changed.


The AE (2019) test file if you get some time and dont mind checking it out.
https://f1.creativecow.net/file/13878/13878_tooltipexample.zip


Return to posts index


Mervin James
Re: Moving anchor point when rectangle is resized
on Nov 16, 2019 at 4:34:50 pm

Is anyone able to help with this please?


Return to posts index

Julien Schickel
Re: Moving anchor point when rectangle is resized
on Dec 3, 2019 at 9:16:54 am

Hello, and sorry for answering so late, I was under a lot of work...

Trying it, I change a few things in order to make it work:

Create, two Slider controls (one for X & one for Y, which I renamed "offset X" & "offset Y") and use these expressions:

for the X one:
S=content(1).content(1).size;
value*S[0]/100

for the Y one:
S=content(1).content(1).size;
value*S[1]/100

On the anchorPoint, paste this one:
R = sourceRectAtTime();
[R.left,R.top+R.height/2]+[effect("offset X")("Curseur"),effect("offset Y")("Curseur")];

And nothing on the position!
That should give the behaviour you're looking after. The anchorPoint won't move from the point you choose when changing the size (although some tuning with the values of the two slider controls will be necessary)

Julien Schickel
Editor & motion designer
https://www.youtube.com/channel/UC7_NVR3JLdhEYDlEQuNFfug


Return to posts index

Max Haller
Re: Moving anchor point when rectangle is resized
on Dec 3, 2019 at 3:35:40 pm

Is there a reason you need to do this with a bunch of sliders and expressions vs just placing a null where you're trying to get the anchorpoint to be?

Whenever I do animations with text bubbles or call out boxes, I just place a null object at the tip of the arrow that sticks out and parent the callout box+text to that. That way you can do your scaling animation directly to the null. Also there's a really useful extension called Move Anchorpoint 2 (There's v3 but its not free, v2 is free) I use that all the time to quickly snap the anchor point to where i want it.


Return to posts index

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