Copy link to clipboard
Copied
Hey,
i have a shape layer (rectangle) and 4 points in my composition.
the 4 points change their position individually to a set position.
i want them to be connected to the edges of my rectangle.
the scale of the rectangle shall change when i move the points to a different position.
is there an expression i could use for this?
Thanks in advance,
Jenny
Edit: Here are the position expressions you should use for each of your four yellow squares:
Top-Left:
thisComp.layer("Rectangle Points (Expression Controls)").effect("Point: Left-Top")("Point");
Top-Right:
[thisComp.layer("Rectangle Points (Expression Controls)").effect("Point: Right-Bottom")("Point")[0], thisComp.layer("Rectangle Points (Expression Controls)").effect("Point: Left-Top")("Point")[1]];
Bottom-Left:
[thisComp.layer("Rectangle Points (Expression Controls)").effect("Point: Left-Top")("Poi
...Copy link to clipboard
Copied
More complicated than it looks at first, because shape layer scale is relative to the comp and based on the actual size of the shape and shape layer coordinates start in the center as opposed to the top left corner liek any other layer. Without knowing your actual sizes and placement, nobody can really give you an exact formula, but you would basically pipe it through two instances of linear() interpolators to figure out the relation - one to go from comp to actual object size in pixels and then the second to relate the pixel size to a scale value. Also you would need to add and subtract the difference of the coordinate origin.
Mylenium
Copy link to clipboard
Copied
I'm not sure if I know exactly what you're asking for but here's a composition I wrote up for you that will draw a rectangle at a position and size based on two user-configurable coordinate points - the upper/left and bottom/right. I made those two points available to be modified via two 'Point Control' expression controls.
The comp is based on a rectangle shape layer whose coordinate system I made based at (0,0) for ease of use. The rectangle was drawn in AE so that the shape path path starts at (0,0) with a size of (5,5). The two-configurable points scale based on that original size of 5,5.
Copy link to clipboard
Copied
Hi,
i tried your method and it worked. But i'm not sure if it's the solution for my problem.
Here are Screenshots from my project:
1. 2.
3.
Here you see the 4 edges (yellow) and the rectangle (dark grey). When the edges change their position, the rectangle shall change its scale according to those positions. In the moment it is just another layer lying underneath them. My wish is that i can change the positions of the upper right und down right yellow edge and the rectangle automatically changes too.
Copy link to clipboard
Copied
Do you really want to use the scale or would it not make much more sense to use the shape's size parameter? I don't have time at the moment, but I might throw together something a bit later.
Mylenium
Copy link to clipboard
Copied
Well i dont really care about how it is done. My first idea was just to use the scale.
Copy link to clipboard
Copied
You're right I'm so accustomed to using bezier shapes that I completely forgot about AE's parametric shapes as well. That would be a simpler solution. I'll modify my solution for that and post the changes later.
Copy link to clipboard
Copied
Unless I'm missing something in your requirements you can fully describe the position and scale of your rectangle with only two points (upper-left, bottom-right), which is why I used only two points in the sample expression I provided. So in your application you can just ignore the bottom-left and upper-right points when using the expression.
Copy link to clipboard
Copied
Here is an updated comp using a parametric-based rectangle instead of bezier (ie, "Bezier Path" box unchecked when creating rectangle shape layer).
Copy link to clipboard
Copied
Nice! That works for me 🙂
Now what do i have to do, if i want to link the yellow edges to the edges of the rectangle?
I tried to use the same expression for the position i used for the rectangle (without the scale expression). but thats not working the way i want it its moving in the right direction and all. but its not really attached to the rectangle.
Copy link to clipboard
Copied
Make sure your yellow rectangle's layer's transformation position value is [0,0]. And the shape group's too.
Copy link to clipboard
Copied
Sorry if i'm not understanding it fast ' i rarely use expressions. i changed the postition to 0,0 but i dont think thats what you wanted me to do..
Copy link to clipboard
Copied
You need to convert the positions using the toComp() layer space transform and or do your own math as I was originally suggesting. Stay tuned.
Mylenium
Copy link to clipboard
Copied
Edit: Here are the position expressions you should use for each of your four yellow squares:
Top-Left:
thisComp.layer("Rectangle Points (Expression Controls)").effect("Point: Left-Top")("Point");
Top-Right:
[thisComp.layer("Rectangle Points (Expression Controls)").effect("Point: Right-Bottom")("Point")[0], thisComp.layer("Rectangle Points (Expression Controls)").effect("Point: Left-Top")("Point")[1]];
Bottom-Left:
[thisComp.layer("Rectangle Points (Expression Controls)").effect("Point: Left-Top")("Point")[0], thisComp.layer("Rectangle Points (Expression Controls)").effect("Point: Right-Bottom")("Point")[1]];
Bottom-Right:
thisComp.layer("Rectangle Points (Expression Controls)").effect("Point: Right-Bottom")("Point");
Copy link to clipboard
Copied
i think i got it! i will tell you when i am ready
Copy link to clipboard
Copied
the bottom left one is stuck! like i want it to be. but i have a problem with the bottom right one. its moving correct in the x coordinate. but when i change the y coordinate its moving (still up and down) but inverted. like when everything should be moving downwards the bottom right one is moving upwards. but the bottom left one is moving like it should.
Copy link to clipboard
Copied
Can you post a screen shot of the bottom-right yellow square. Please expand all properties of both the original rectangle and bottom-right layers including the transformat properties and the full position expression you're using for the bottom-right.
Copy link to clipboard
Copied
i realized i didn't thank both of you properly
i changed my yellow edges and now its working! thank you very much for your effort. I really appreciate it !
greetings,
jenny
Copy link to clipboard
Copied
okay i think i know why. those yellow edges i showed you before. i created just one and duplicated that one and changed them by rotating them. i rotated one of them like the bottom left one (the first i created) and know they are moving correctly.
it was my fault ^^
Copy link to clipboard
Copied
Here's a ready-to-use setup that you can study:
Dropbox - Technique_Shape_Layer_Square_00.zip
I already structured things in a way that you can freely change the design inside the groups. The square is resized using the top left and bottom right corner handles.
Mylenium