Skip to main content
Participant
February 16, 2021
Answered

Maintaining stroke width, while scaling height and width independently

  • February 16, 2021
  • 3 replies
  • 8218 views

Hi there,

 

I've created a two concentric boxes, meant to look like a computer/browser window(first image). I'm trying to figure out how to scale the height and width independently, while maintaining stroke width. I've made two rectangle shape layers of the same stroke, and applied the following expression to stroke width of both:

 

value / length(toComp([0,0]), toComp([0.7071,0.7071])) || 0.001;

 

Now if I scale either of the boxes(or both together with a null) this works fine, and stroke is maintained.

 

However, the upper/inner box needs to have keep a constant height, and I'd like to be able to resize the larger/outer into a variety of shapes, rather than just the current 16:9 shape.

 

But if I try and seperate the scale width from height and alter either independantly, the expression doesn't seem to work. (I don't get an error, but the strokes just expand or compress with the scale). Any ideas why? Or would anyone have a alternative workflow or workaround that could do it? 

 

I don't have a particularly great understanding of expressions(just got this from Dan Ebberts), so there might be something obvious that I'm missing here. Hopefully one of you lovely people can help me out!

 

 

This topic has been closed for replies.
Correct answer Mylenium

Still not an issue that would require any expressions. Simply add the stroke at the bottom of the stack of the shape groups at the root level. You know, this stuff can be organized and grouped as you see fit and the stroke can just as well be applied after all transforms.

 

Mylenium

3 replies

LW0121
Inspiring
May 23, 2024

I keep using this expression but right now, like After effects 2024 report this expression has bug/error although it still works. Anyone could help me to fix this? 

 

Dan Ebberts
Community Expert
Community Expert
May 23, 2024

Can you post a screen shot of the the error message?

LW0121
Inspiring
May 23, 2024

Sure, like this~

Mylenium
MyleniumCorrect answer
Legend
February 17, 2021

Still not an issue that would require any expressions. Simply add the stroke at the bottom of the stack of the shape groups at the root level. You know, this stuff can be organized and grouped as you see fit and the stroke can just as well be applied after all transforms.

 

Mylenium

Participant
February 17, 2021

Thank a million! That works perfectly now. Really appreciate the help!

Mylenium
Legend
February 17, 2021

Completely wrong approach. You don't scale the graphic, you animate the sizes of the underlying masks/ shape layer rectangles. this has nothing to do with any expressions. It's simply a bad workflow to start with.

 

Mylenium

Participant
February 17, 2021

Hi Mylenium, 

 

Thanks for that. I had tried that approach, but when I adjust the sizes of the rectangles directly from the shape layer (in this menu - Contents -> Rectangle 1 -> Rectangle Path 1 -> size) they resize from the centre (picture attached), as there is no anchor point option for this approach, meaning that everytime I resize the boxes I will need to reposition them also, which isn't ideal. My approach used scale instead because having an anchor point means I can pin it in the corner for both boxes and they will stay together when it scales. Is there something I'm missing here?