4 Replies Latest reply on Aug 10, 2014 5:39 AM by Rick Gerard

    Scale path without affecting stroke width

    mumbly_j0e Level 1

      Hi all,

       

      This seems like it should be simple to do but I'm not having any luck here. Basically I have a path parented to a null that controls several things, scaling them down, rotating and moving across the composition. One of those items is a path with a stroke of 32 px.  I want to be able to scale the path itself down, but leave the stroke the same.

       

      I thought I could key the stroke width manually but that has no effect- scaling it up as the path scales down doesn't seem to change the stroke width at all at the end keyframe, only at the beginning keyframe. I see the px count start at 32 and increase up to as it moves along the timeline, even though the stroke width on screen is still getting smaller as if there were no change at all to the width.

       

      Thanks!

        • 1. Re: Scale path without affecting stroke width
          Rick Gerard Adobe Community Professional & MVP

          You generally don't want to scale the layer that contains the stroke, you want add keyframes to the mask path and animate the size of the path. This is easy. You just start by double-clicking one of the vertices and using the transform box.

           

          If this technique does not work for you then you have two other options, both involving expressions. Both of these options use exactly the same expression to look at the scale of your null layer and both assume that the null is at 100% scale at the start of the animation. The option that I would choose would be to replace the mask path on a layer with stroke applied with shape layer path with stroke applied. You have so many more options and you're dealing with vector information. With either solution this is the expression.

           

          sf = thisComp.layer("Control Null 1").transform.scale[0]/100;

          ov = value;

          nv = ov / sf

           

          sf (scale factor) is the x scale value of the controlling null that is the parent of the stroke layer or the layer with the stroke effect applied to a mask divided by 100. If you intend to scale X and Y of the parent you'll have to modify the expression and then combine the scale factors and this solution will not work as well.  The original scale value is divided by 100 to turn it into a decimal value


          ov (original value)  is the original set value of the stroke.

           

          nv (new value) is calculated by dividing the original value by the scale factor.

           

          This is just basic algebra from the 7th grade. If your controlling parent is scaled below 0 then the stroke will go away because the value will change to a negative number. If this is necessary in your composition you can write an if statement that will change the nv back to a positive number if the scale factor becomes less than or equal to zero and solves the divide by zero error you would get with a scale factor of zero.

           

          One last point, and this is important. This expression will produce accurate results if applied to the brush size of a mask path when using the Effects>Generate>Stroke effect to create your line but when scaled over 100% the line will begin to fall apart and anti aliasing will not be able to keep up with pixilation caused by the scale. Over about 120% the line will start to look thinner and over 140% it will look bad even though the stroke width is numerically accurate.

           

          I'll let you take it from here.

          • 2. Re: Scale path without affecting stroke width
            Mylenium Most Valuable Participant

            Without understanding exactly the structure, nobody can tell you anything. Provide scereenshots of the timeline with the relevant properties visible.

             

            Mylenium

            • 3. Re: Scale path without affecting stroke width
              mumbly_j0e Level 1

              Thanks Rick, I got it to work as suggested.

              • 4. Re: Scale path without affecting stroke width
                Rick Gerard Adobe Community Professional & MVP

                Glad to help. Please mark the question as answered so others can find the solution to similar problems.