Copy link to clipboard
Copied
I have a simple rectangle shape layer that I want to control (only the width) with slider control using expression. How do I do that?
Thanks in advance.
You could try something like this for anchor point:
w = content("Rectangle 1").content("Rectangle Path 1").size[0];
[-w/2,value[1]]
Dan
Copy link to clipboard
Copied
With a Size expression like this:
w = effect("Slider Control")("Slider");
[w,value[1]]
Dan
Copy link to clipboard
Copied
Thanks, Dan for your quick reply.
I tried your expression and it works like a charm.
However, I should have mentioned that I wanted this shape layer to grow and shrink from the left side (with an anchor point at the far left).
I have the anchor point at the far left, but nonetheless with this expression, it grows and shrinks from the middle.
How can I fix that?
Thanks again so much for your help.
Copy link to clipboard
Copied
You could try something like this for anchor point:
w = content("Rectangle 1").content("Rectangle Path 1").size[0];
[-w/2,value[1]]
Dan
Copy link to clipboard
Copied
Is it possible to do this so that it transforms from the actor point at right?
Copy link to clipboard
Copied
Switch off the expression, grab the Pan Behind/ Anchor Point tool, drag the Anchor Point to the Top Right corner.
Switch the expression back on. Now it should scale from the new anchor point?
Copy link to clipboard
Copied
I got width to work, I cant seem to get height. Please help!
Thanks,
brian
Copy link to clipboard
Copied
What do you have that's working, and what are you after, exactly?
Copy link to clipboard
Copied
I got it working now! Sorry I am terrible. Thanks for your support!
Copy link to clipboard
Copied
Is there a way to lock HEIGHT position instead of the WIDTH?
I'm still a bit new with expressions, so I don't know how to flip this expression so the rectangle path in the shape layer would be anchored at the top and a slider would adjust the path going down.
Thanks in advance for the assist.
Copy link to clipboard
Copied
Use Dan's expression for the anchor point and change it to:
w = content("Rectangle 1").content("Rectangle Path 1").size[1];
[value[0],-w/2]
w = content("Rectangle 1").content("Rectangle Path 1").size[...]; -> taking the size of the rectangle and store it in the variable w.
...size[] is an array with two values, x and y. To access on of those values, you write size[0] for x and size[1] for y.
[value[0],-w/2] is an array for x and y values, too. value[0] is the x value of the anchorpoint. This is a way to use an expression along with the possibility to change a value by entering it or drag it.
-w/2 takes half of the y-size of the rectangle and moves the y-value of the anchorpoint by this amount, aka to the top of the rectangle. If you change -w/2 to w/2, the anchor point is pinned at the bottom of the rectangle.
It's easier to understand, if you use actual values:
Rectangle is x = 100, y = 200.
Anchorpoint is at x = 0, y = 0 (in the middle of the rectangle)
Coordinates of the top edge are 0,-100
Coordinates of the bottom edge are 0,100.
(Coordinates of the left edge are -50,0.
Coordinates of the right edge are 50,0.)
w = content("Rectangle 1").content("Rectangle Path 1").size[1];
= 200 (y-value of the rectangle)
-w/2
= -200/2
= -100
Coordinates for the anchorpoint are:
[value[0],-w/2]
= [0, -100]
= top edge.
Cheers,
Martin
Copy link to clipboard
Copied
Similar question, but how do I control the width and height of a rectangle separately with slider control using expression?
Copy link to clipboard
Copied
A Size experssion like this maybe?
w = effect("Width Control")("Slider");
h = effect("Height Control")("Slider");
[w,h]
Copy link to clipboard
Copied
Works perfectly! Thank you so much for your help!