15 Replies Latest reply on Nov 13, 2014 9:34 AM by Rick Gerard

    Relative positional Scaling without distortions

    dissidently Level 2

      The bars on the left of this image, when scaled as a group, give the result in the middle.


      What sort of nesting arrangement of layers and groups is required to get the result on the right?


      Screen Shot 2014-11-09 at 12.04.50 PM.png

        • 1. Re: Relative positional Scaling without distortions
          Andrew Yoole MVP & Adobe Community Professional

          You will need to separately animate each element, rather than generally scale one group.  You can either do this manually, or use expressions and controllers to manage the relevant scaling.

          • 2. Re: Relative positional Scaling without distortions
            Rick Gerard Adobe Community Professional & MVP

            If it were me I would use a separate text layer for each number and a single shape layer for the grid. Inside the grid would be 8 rectangles. I would tie the position of the text layers to the position of each of the rectangles in the shape layer and gang all of the rectangle size animators together with expressions. If I get the time I'll post the expressions. I think the one for position would be something like this:

            masterP = thisComp.layer("Shape Layer 1").position;

            h = thisComp.layer("Shape Layer 1").content("Rectangle 1").content("Rectangle Path 1").size[1];

            n = index -1;

            y = masterP.value[1] + (h * n);

            x= masterP.value[0];

            [x, y]

            You would put it on all layers below the first shape layer. You could also apply this expression to all text layers but adjust the anchor point so the text layers lined up with the bars. You then animate the size of the rectangle in shape layer 1.

            • 3. Re: Relative positional Scaling without distortions
              dissidently Level 2

              Thanks Rick!


              I'm a little dull though, on how position information exists in AE.

              Is the below seeking out a position point relative to the layer based on the size of the rectangle?


              If so, how is the process reversed so that the size can be set by way of the scaling process?

              h = thisComp.layer("Shape Layer 1").content("Rectangle 1").content("Rectangle Path 1").size[1];

              • 4. Re: Relative positional Scaling without distortions
                dissidently Level 2

                It probably looked like I was using blending with a slight overlap to get the highlight bars, I'm not. For various reasons I'm using a line with a stroke, as per this image:


                Screen Shot 2014-11-09 at 4.39.37 PM.png

                • 5. Re: Re: Relative positional Scaling without distortions
                  Rick Gerard Adobe Community Professional & MVP

                  I took a stab at your project and came up with these thoughts. First, if you use groups of 3 layers, one for the line, one for the box and one for the number and you parent the line and the box to the number you can use index/3 as a multiplier for the position of the rectangles and the lines. Also, if you use Trim Path's and divide the width - height by the circumference of the rectangle and create a percentage you can use a rectangle with a stroke and no fill to create your line and get it to stick to the box. You can do that with parenting or expressions. You can also add a extender value to the width to get your lines to extend past the edge of the box. Another expression dividing half the height and width of the rectangle will put the anchor point of the rectangle in the upper left hand corner.


                  I tied the box and the line (really just a box with a stroke) together as the first two layers using expressions so that you could animate the size of the box and the width of the stroke. I then added a text layer below and used a simple expression applied to the source text to give the text layer a value counting down from 14. Here's that expression:

                  15 - Math.round(index/3) + ' '

                  Then I duplicated the three layers and used Ctrl/Cmnd + [ to move the duplicates to the bottom of the timeline.


                  Next I modified the expressions for size and stroke width in the duplicates so that they were referring to the first box and line shape layers. I then wrote this expression for position of the text layer.

                  masterP = thisComp.layer("01 ").position;

                  h = thisComp.layer("Box 1").content("Rectangle 1").content("Rectangle Path 1").size[1];

                  n = 1 - index/3;

                  sw = thisComp.layer("Line 1").content("Rectangle 1").content("Stroke 1").strokeWidth/2;

                  y = masterP.value[1] - ((h) * n) + sw ;

                  x= masterP.value[0];

                  [x, y]

                  It's all pretty simple and nothing more than simple high school math. It took me about 15 minutes to put this together. Here's a project file for you to play with. I hope you have CC. Dig into the expressions and you'll figure it out. BTW, I saved everything as a set of 3 animation presets so I can apply them to any new comp and recreate this animation easily. I'd suggest that you do the same. Try selecting the bottom 3 layers and pressing Ctrl/Cmnd + D then Ctrl/Cmnd + [ to add more layers to the comp.

                  Screen Shot 2014-11-09 at 10.30.24 PM.png

                  • 6. Re: Relative positional Scaling without distortions
                    dissidently Level 2

                    Rick, THANK YOU!!!


                    I'll dig into this and see how it all works. Just wanted to say THANKS... right now.


                    As you say... simple for YOU!


                    15 minutes for you would be 500 hours for me because there's no straight forward way to learn the relationships between entities within AE, and it looks and feels like they don't care to figure out how to explain the core (or whole) in a meaningful way that might provide this kind of insight.


                    Every time I see a help file referencing external websites I groan, audibly. The rot is in.


                    All terribly sad because there's some enormous capabilities in After Effects, and it's far and away the best of the Adobe apps.


                    For me, this is as much learning about the potential relationships and positional processes/methodologies of AE as it is about its scripting and then the "programming" of hooking things up, because I'm not an AE native.


                    Will be back with results...

                    • 7. Re: Relative positional Scaling without distortions
                      dissidently Level 2

                      One potential problem with this approach, and I'm sure there must be a work-around that's beyond me, is that I'm using this column of boxes as a background for a graphing line of RPM values, and when scaling that graph line, it's done from the middle (Y) of the comp, as that's how it should look to happen.


                      However with this approach of scaling from the top by way of the expansion of one of the rectangles, finding that midpoint for this series of rows seems... to me... impossible.


                      The main issue being that the graph line of RPM values must remain exactly relative to its positions as represented by the rectangles that delineate the values.


                      Here's a mockup of one of the objectives I did by playing around with some masking. I can get that graph line behaving as I want, it's a very simple scaling of a Y-Scale Slider I have linked to various elements to make it scale from the middle of the Y of the containing Composition.


                      Any thoughts on how to introspectively make the lines and rectangles move relative to a "real world" graph of values as it scales?


                      Screen Shot 2014-11-09 at 2.35.57 PM.png

                      • 8. Re: Re: Relative positional Scaling without distortions
                        Rick Gerard Adobe Community Professional & MVP

                        I'm confused as to what you are after here because I'm having a hard time visualizing how pleasing it would be to have the size of the boxes correspond to the values in the line over time.


                        If you want to tie a variable, which would be the y value of your line then you have to have a way to pull that y value out of the line. If the line can be converted to a path then you can turn the path into a motion path and apply that to a null then use the change in y value to drive the change in y values of your lines. You can use an expression to do set up a relationship between the Y value of the moving null and the width of the boxes so a change in y of the null from 200 to 800 would give you a change in the output value of the expression from say 50 to 200. That expression would look like this:

                        y = value[1] + linear(t, 800, 200, 50, 100);

                        I added a new comp to the sample project that shows the technique. Pay close attention to the expressions driving the size of Box 1 and the anchor point of Text 01. stacked and animated shape layers_CC.aep

                        • 9. Re: Re: Relative positional Scaling without distortions
                          dissidently Level 2

                          I'm a little uncomfortable talking directly about what this is for, but can talk more directly than I have.


                          The line you see represents the revs per minute of a racing vehicle's engine as it's going around a race track.

                          The start of the track is at the left, the end at the right.


                          This line represents pretend data, the effort is to replicate the look and feel of a UI to be developed based on the animations made that demonstrate the functionality desired ... for racers to analyse the data coming from their vehicles.


                          Analysis involves taking a close look at the data, both in terms of zooming the X axis, and expanding the Y axis to take up more space so as to provide a more granular examination of the data.


                          Imagine this on an iPad, the user using two fingers in a pinch gesture along the X axis to zoom/contract the data in that manner, and a vertical pinch to expand the height of the Y-axis.


                          Again, thanks very much for your help, Rick. You're knowledge of the ways and means of AE is massively impressive.

                          • 10. Re: Re: Relative positional Scaling without distortions
                            dissidently Level 2

                            I'm going to get stuck into figuring out what all your fancy code stuff does in a minute... just wanted to throw this together so you can see the rest of the scope of the problem... if you're at all interested:


                            Comp 1.png

                            • 11. Re: Relative positional Scaling without distortions
                              Rick Gerard Adobe Community Professional & MVP

                              How did you generate those curves? Unless they are a vector path they are almost useless in driving other animation.

                              • 12. Re: Relative positional Scaling without distortions
                                dissidently Level 2

                                Yes, these are hand drawn shape paths, made up of the useless AE vertices. Which I think (I don't know all the terms Adobe uses) is a vector curve.


                                I've then made closed shapes out of them to do the shading/fills, and kept a single copy open to use as the line/stroke that defines it for the viewer.


                                I say "useless vertices" because there's so little these vertices have in terms of properties. It's as if the vertices know nothing about each other. Stunned (still) that there's no vertex or edge or section snapping in AE.

                                • 13. Re: Relative positional Scaling without distortions
                                  Rick Gerard Adobe Community Professional & MVP

                                  Because those are hand-drawn shape paths you can use them to drive all kinds of other animated properties very easily. Any path that has vertices can be turned into X and Y values by selecting the path, setting a keyframe, copying the keyframe, then selecting the position property of any other layer, setting a single key frame for position and then, with that keyframe selected "Paste." You have now converted your  path to X and Y values that change over time. Using the linear expression I demonstrated above you can then drive any property in any effect that can be expressed in a number or an array.


                                  You could, for example, change the hue or situation or even the color of an effect, control distortion, opacity, scale, or as demonstrated in the sample comp, size of a rectangle.


                                  When I am planning a complex animation like yours I always create a simple storyboard schematic to help me plan the animation. These are usually just a simple sketch on a piece of paper with a few notes. Getting into the habit of analyzing what you want to animate and figuring out where you can drive multiple animations with one property will save you a lot of time in the long run. Creating that map will also help you understand how After Effects works and become proficient in much less time.

                                  • 14. Re: Relative positional Scaling without distortions
                                    dissidently Level 2

                                    Rick, thanks for the help.


                                    Sorry, traveling at the moment and can't immediately test what you're suggesting, but let me see if I've got this straight:


                                    From what you're saying, I can take a line (that's called a path within a shape) and then make a keyframe of one position in time, of that line (I don't even want to get started on how counter-intuitive this is) that then stores all the values of that line, somehow, but never makes them available anywhere else, other than the paste buffer.


                                    Is that right?


                                    That having copied all those vertices via that keyframe into the paste buffer, the entire line's vertices can now be applied via pasting to (for example) a position property?


                                    Does this then generate an exact copy of the line in the position values of that object in the timeline


                                    I have the drawing out of the animations, and its features, in great detail. And I know how to realise it in 3ds Max because I understand all of its methodologies and relationships between objects... and their properties. The interesting thing about what I'd call "pro" apps, is that they provide equal levels of access to all properties as they do objects.


                                    AE doesn't seem to be like this. It doesn't give properties the same level of access to the user as it does objects. They seem to treat properties (like vertices and their location) as much poorer cousins.

                                    Secondly, it feels like the relationships between objects in AE is nowhere near as well thought out, and as to how it's expressed... well, I'm here, not reading a manual, because there isn't such a thing for this sort of thing, apparently. It doesn't seem as though anyone is interested in writing an actual manual that details these relationships between objects, properties and time in a meaningful manner that pertains to production and provides sufficient overview to then make the rest of the apps features intuitively discoverable.


                                    I believe that's because there's nothing much intuitive about the formation of AE, that it's a bit of a mongrel of ideas, methodologies and mechanics that largely requires rote learning of functionality and approaches.


                                    • 15. Re: Relative positional Scaling without distortions
                                      Rick Gerard Adobe Community Professional & MVP

                                      I felt exactly the same way when I started to learn how to use 3D apps. Nothing made any sense to me.


                                      Vertices from a vector path are a unique blend if information and in AE are always expressed in the X Y plane. To read those values you have to apply them to a position property. If you were to copy a single keyframe from a vector path and paste it to the position property of a null or say a small solid the solid would follow that vector path exactly as long as the layer with the vector path was not scaled. Scaling happens after the vectors are calculated so copying the vector info does not reflect the scale.


                                      When you have applied the vector info to a path property you have a perfectly matched description of the path over time with X and Y coordinates that you can use to drive any property that has numbers.


                                      In AE there is no direct translation of vector information to another vector. You can do some of that with expressions but AE is always based on pixels and not vectors so, unlike a 3D app, the size of the world is always limited to the available pixels. AE's 3D space is also based on pixels.


                                      As far as expressions are concerned, they are pretty easy to figure out. If you have more than one value in a property it is expressed in an array. For example color is always 4 values, r, g, b and alpha and the range for color is 0 to 1 with a maximum of 32 bit precision so that's billions of colors. To add an expression for a 50% transparent pure red color you would use this array: [1, 0, 0, .5].


                                      Position properties are X Y and Z so an expression to position a layer's anchor point at the center of a composition no matter what size the comp is would be [thisComp.width/2, thisComp.height/2, 0] The zero for the z value is because zero is always the center of the Z space in a comp. There is no setting in composition settings for the z size.


                                      Simple java math and a few specific functions are all that is required to create most expressions. Time is measured in seconds, AE can figure out when the in point and out point and keyframes occur in the comp, and AE knows what size the layer is no matter what kind of footage is involved. AE can sample a color in the pixel grid. It's all pretty standard stuff and you can figure out most of it from AE's help section and a book on Java math.