Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Animating an Image Border

New Here ,
Jul 11, 2023 Jul 11, 2023

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

Linda27495954al7a_0-1689109406621.png

 

TOPICS
Expressions , How to , Scripting
722
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2023 Jul 11, 2023

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 12, 2023 Jul 12, 2023
LATEST

iExpressions contains an expression to create a path for a background box around any layer and resizes automatically:

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines