Copy link to clipboard
Copied
Hello,
I’m trying to make a template and one of the things I'm trying to achieve is having a stroke/border around any image that has a trim path animating from the same location (lower right corner) for any size picture.
Is there an easy way to achieve this and make it easily copiable
Also I need the stroke/image border width to stay the same/consistent
Copy link to clipboard
Copied
If your images are all the same size, you can create a rectangle with trim paths animated either by keyframes or layer in and out-point, then save the shape layer as an animation preset.
If your images are different sizes, you can use sourceRectAttTime() or layer width and height to get the size of the layer and use that to drive the size of the rectangle with an expression. If you use index - 1 instead of the layer name in the expressions and put the Shape layer below the footage layer, your expressions will always work.
I have a bunch of animation presets that I have saved that use layer in and out points to animate all kinds of things. I also have a bunch of animation presets that apply all kinds of animations to layers that are above or below one layer.
Here is a set of expressions for a shape layer that looks at the layer above it and creates a rectangle, applies Trim Paths, animates the path from the top right corner in a clockwise direction for 40 frames, and keeps the shape layer lined up with the footage layer no matter where it is in a 2D or 3D composition as long as the shape layer and the footage layer are both 2D or both 3D.
// Rectangle 1/Size
ref = thisComp.layer(index -1);
s = content("Rectangle 1").content("Stroke 1").strokeWidth;
w = ref.width * ref.scale[0]/100;
h = ref.height * ref.scale[1]/100;
[w + s, h + s]
//Rectangle 1/Transform Rectangle 1/Rotation
-90;// to set the start at the top left corner
//Rectangle 1/Trim Paths/End
strt = time - thisComp.layer(index-1).inPoint;
t = strt / thisComp.frameDuration;
ease(t, 0, 40, 0, 100)
//Shape Layer/Transform/Position;
ref = thisComp.layer(index -1);
ref.position;
You can choose Stroke options like Projecting Cap, Rounded Cap, or Round join if you like. If you want a 20-frame duration, change the 40 to 20. If you want to start at the bottom left corner, change the Rotation value to 180. You can also tie in the reference layer's Rotation property with a simple thisComp.layer(index - 1).rotation expression. As long as all the other parameters on your Shape layer are at their default values, the shape layer will always be the same size as the layer above it, and the animation will start when the layer above starts.
If you want, you can add expression controls for color, stroke width, and any other customizable property, then select the Contents and the Effects you use as any and save this as an animation preset. You'll get an animation preset you can double-click at any time, with no layers selected, drag the new shape layer that is created below any layer, and you'll get an animated stroke that starts moving when as soon as the layer above's in-point is passed.
I hope this helps get you started.
Let me know if that's not what you want.
Copy link to clipboard
Copied
iExpressions contains an expression to create a path for a background box around any layer and resizes automatically:
Find more inspiration, events, and resources on the new Adobe Community
Explore Now