3

I think it would be easier to share an image to show what I'm trying to accomplish. offset path angle for each yellow corner

This will be a mogrt so the actual rectangle size / aspect ratio is determined by variable text size.

But, I think I should still be able to figure out offset angle so the trimmed paths will always be centered on the corners.

Edit: Getting a bit further but still not there. This should make the yellow stroke start directly in the lower right corner, but it doesn't.

enter image description here

# text layer determines width and height
txt=thisComp.layer("quote").sourceRectAtTime();

# padding adding to width and height
p=thisComp.layer("controls").effect("box padding")("Slider");
h=txt.height+p;
w=txt.width+p;

# angle from upper right corner to lower right corner (yay trigonometry)
x=radiansToDegrees(Math.atan(h/w))*2;
[x]

I still haven't figured out how I'm going to account for the length of the line yet (in degrees).

Edit 2: Decided to take a different approach and use a mask with 2 rectangle shapes (controlled with a second slider)

alternate approach any size works

The yellow stroke shape uses the dual rectangle shape layer as a track matte and I'm using these two expressions to determine the width/height of the rectangles.

txt=thisComp.layer("quote").sourceRectAtTime();
h=txt.height;
w=txt.width;
p=thisComp.layer("controls").effect("box padding")("Slider");
sw=thisComp.layer("controls").effect("stroke length")("Slider")
x=w-sw;
y=h+p*2;
[x,y]

txt=thisComp.layer("quote").sourceRectAtTime();
h=txt.height;
w=txt.width;
p=thisComp.layer("controls").effect("box padding")("Slider");
sw=thisComp.layer("controls").effect("stroke length")("Slider")
x=w+p*2;
y=h-sw;
[x,y]

I won't be able to animate the way I had planned, but I should still be able to come up with a cool look by animating the track matte. I'm leaving this question open because I would love to know why my first solution wasn't correct.

Edit3: Thanks for the answer Clif!

solution

1 Answer 1

2

In order to align the lines to each corner, I was able to do this:

Bottom left corner:

  • No offset
  • Set trim start to 50%
  • Set trim end to 50%
  • Set expression on trim end to be 100 minus the trim start or something like 100 - content("Rectangle 1").content("Trim Paths 1").start
  • Now if you change the value of the trim start, it should stay equidistant with the trim end.

This first corner can be used as a starting point for all of the other corners and we should only have to update the offset to get them to align correctly to each corner.

Top right corner

  • Set offset to 180 degrees

Bottom right corner

  • Set expression for offset to be:
// If needed, change your width and height variables to whatever values you 
// are using to drive your dimensions.
width = content("Rectangle 1").content("Rectangle Path 1").size[0];
height = content("Rectangle 1").content("Rectangle Path 1").size[1]
perimeter = 2 * width + 2 * height;
perc = width / perimeter;

-perc * 360

Top left corner

  • Pickwhip the offset of the bottom right corner and add 180.

Then you should be able to hook up each of the trim path's start positions to a 'slider control' effect to have them all animate together.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.