10 Replies Latest reply on May 8, 2017 11:17 AM by Roei Tzoref

    Scale by proximity script

    GeoffKornfeld

      Hi all,

       

      I'm searching for an expression I can use so I don't go insane. See the attached image. I want each number to scale from 100% to 150% as the red line approaches. So if the red line is 200 or more pixels away from the number's anchor, the scale is 100%. If it's right on top, it's 150%.

       

      Thank you.

       

        -  Geoff

       

      Timeline.jpg

        • 1. Re: Scale by proximity script
          Rick Gerard Adobe Community Professional & MVP

          Let me get this straight. The red vertical line moves along the timeline. As the red line approaches a date the text scales up. If each date is on a separate text layer then you could use the position of the red line and a length method to scale as the red line approaches. If all of the dates are on the same layer then you could use a text animator for scale and just keyframe by hand. You could also use timeline markers and an expression based on time. It all depends on how much monkeying around you plan to do when setting up the composition, the length of the shot and how many changes you need to make.

           

          If I had a narration track that I was using to time the movement of the red line I"d just throw a couple of markers in the timeline to indicate kay points, animate the position of the red line, then use a text animator for scale and animate by hand. It would take seconds to get the timing correct.

           

          If I needed to build an automated system that followed the movement of the red line I would probably use a length method tied to the anchor point of each date layer. Put the anchor point of each date layer in the middle of the date and then use the same length method to ease the scale up and down for the text layer.

           

          I'm no where near AE right now and wouldn't attempt to write the expression without checking it in AE but it should be pretty straight forward.

          • 2. Re: Scale by proximity script
            GeoffKornfeld Level 1

            I think you understand my problem conceptually, I just don't know anything about expressions, so I'm hoping someone can give me something that I can edit and paste into the scale of each number.

            • 3. Re: Scale by proximity script
              Rick Gerard Adobe Community Professional & MVP

              Try naming your red line layer "Red Line" and using this expression for scale on a text layer:

              t = length(position, thisComp.layer("Red line").position);

              s = ease(t, 200, 0, 150, 100);

               

              [s, s]

               

              The Length method is under the Vector Math section of the expression language menu, the ease method is under the Interpolation section.

               

              You are measuring the length between the anchor point of the current layer and the anchor point of the Red Line layer. Then a simple interpolation method takes the length ("t" for temporary value of length) and applies an ease when t starts at 200 and ending at zero between 150 and 100. The result of the interpolation method translates to scale for the layer with the expression.

               

              For this to work properly the text layers should be created with the anchor point directly in the center of the text in a center justified paragraph. You can easily center the anchor point by using the baseline shift property in the Character Panel. Start by using the resetting the position of any text layer you created by clicking with the type tool anywhere in the comp panel and typing, then match the baseline shift for every layer.

               

              That should do it.

              1 person found this helpful
              • 4. Re: Scale by proximity script
                Roei Tzoref Adobe Community Professional
                I just don't know anything about expressions, so I'm hoping someone can give me something that I can edit and paste into the scale of each number.

                 

                I would recommend also trying here:

                After Effects Expressions

                 

                or here:

                CreativeCOW

                 

                who knows, you may very well be touched by the Expressionist Dan Ebberts himself. may he continue to bless us with his unparalleled Ae coding talent for years to come...

                 

                *EDIT: I can see Rick found the time.

                • 5. Re: Scale by proximity script
                  Rick Gerard Adobe Community Professional & MVP

                  I hope I got the expression right. If it works as expected great, if the layers scale down when you approach the text layer reverse the 150 and 100...

                  • 6. Re: Scale by proximity script
                    Roei Tzoref Adobe Community Professional

                    it works perfectly, Rick. thank you. let's see if Op gets it too. here's a visual:

                    158.gif

                    • 7. Re: Scale by proximity script
                      GeoffKornfeld Level 1

                      Thank you so much for this. It seems I had an issue though in that it didn't work because I have the timeline, including the numbers, parented to a dummy object (called "base"). The red line isn't attached to that, but I've attached it now and things work fine. Just means I need to re-animate it, which isn't a big deal, now that I have this script.

                       

                      Though I'm curious, is there any way to make this work if the Red line isn't also a child of the same parent as the numbers?

                       

                      Thanks again.

                      • 8. Re: Scale by proximity script
                        Roei Tzoref Adobe Community Professional

                        GeoffKornfeld I am merely a sidekick in this thread. expressions are not easy for me, you should really mark rick's response as correct. Re: Scale by proximity script since it also provide useful explanation to what its actually doing.

                         

                        as for the parenting situation. you can parent the redline and disable the parenting using this for the position parameter of the red line:

                        value-parent.transform.position
                        

                         

                        it will shift in position, you can place it where you need to. now the red line is parented but its position is not affected by the null.

                        there's gotta be a more elegant expression then this... but it works

                        • 9. Re: Scale by proximity script
                          GeoffKornfeld Level 1

                          Thanks much. Makes sense.

                           

                          And I just have marked Rick's as the correct one now. I realized my error a second after I marked yours, but didn't know it was undo-able. This is my first time on the forum.

                          • 10. Re: Scale by proximity script
                            Roei Tzoref Adobe Community Professional

                            welcome to the fun house