-
Self – Resize a Bezier Path Shape Layer to Comp size and more
Hey Folks,
I’m trying to create a frame that automatically adjusts its size to the size of any composition.
I’ve already opened a discussion and I collect enough informations to create a new complete thread I hope.
This is the other discussion:
Returning to us…
The frame I’ve is a Rectangular Shape Layer converted to a Bezier Path.
I’ve added a Stroke on the rectangle in order to create the frame border and I’ve also added a Trim Path to access the Start and End animation parameters.
The main problem is that I would like to use this expression on the End property of the Trim Path:
linear (time, 0, thisComp.duration, 0, 100);
With this expression, the rectangle’s stroke automatically build itself from 0 to 100 based on the composition duration.
At this point I would like to have the possibility to change the size of the composition and consequently scale the size of the Shape Layer automatically to comp size.
In order to do this, Dan Ebbert recommended me to apply this expression to the Path property of the Shape Layer:
p = thisProperty;
r = sourceRectAtTime(0,false);
pts = p.points();
newPoints = [];
for (i = 0; i < pts.length; i++){
newPoints.push( [pts[i][0]*thisComp.width/r.width,pts[i][1]*thisComp.height/r.height]);
}
createPath(newPoints,p.inTangents(),p.outTangents(),p.isClosed())
The expression works but when the Trim Path End value is less than 50% or the Trim Path Start value is greater than 50%, the Shape layer begins to expand:
https://www.youtube.com/watch?v=FmgrOoaovRM
The last thing I would like to do is to be able to change, using a Slider Control on a Null object, the initial vertex from which the frame begins to build up.
In order to do so, I found an effective method that allows you to create Keyframes together with an expression that allows you to use them as options.
Here the steps:
I select the top left vertex of the Shape Layer and make a Keyframe on the Path property.
I move forward on the Timeline with the cursor, I select the top right vertex of the Shape Layer and I make another keyframe.
Likewise for the other two vertices.
At this point I create a Null Object and apply a Slider Control on it.
Last step is to add this expression to the Keyframed Path property and connect the Slider Control to the expression:
n = Math.round(thisComp.layer(“NullObject_Name”).effect(“SliderControl_Name”)(“Slider”));
n = clamp(n,1,numKeys)
valueAtTime(key(n).time);
Now it will be possible to change the starting point of the building up frame using the Slider Control, with the values 1, 2, 3 and 4 (as many options as the keyframes).
https://www.youtube.com/watch?v=t8OtXayvOYc
I realize that there are many functions that should work together on a single Path property with a single expression but I would like to understand if there is a way to link them all together or if there’s an alternative way to do so.
I hope I was clear enough.
Thanks in advance
Resize a Mask Path or a converted Bezier Path Shape Layer to Comp size
That’s so true, I used to go with the double-click but then something happened in my life and now I’m going this way