5 Replies Latest reply: Apr 4, 2013 10:39 AM by Dan Ebberts RSS

    The value of this expression

    Cris is Bliss Community Member

      I was looking through some old tutorial projects and came across this expression

       

      [thisLayer.width/2, thisLayer.height/2]

       

      which was applied to the Wipe Center property of the Radial Wipe Effect.

       

      Basically it places the wipe center in exact center point of a layer.   I thought that it had some special power like if the layer were scaled in un-equal amounts, it would prevent something funny from happening, but it works just as if the wipe center were place by hand in the center of the layer. 

       

      Then I changed it to

       

      [thisComp.layer("flower").width/2, thisComp.layer("flower).height/2]

       

      thinking it would cause the placement of the Wipe Center to jump to a different position, the center point of the Flower layer which was positioned off center of the composition.  But it stayed right in the middle of "this layer".

       

      So I wondering is there anything special about this expression other than figuring out the math and keeping, in this case, the property Wipe Center in the center of the layer.

       

      I just trying to understand expressions better.

       

      Thanks

       

      on a mac  CS 5.5

        • 1. Re: The value of this expression
          Mylenium CommunityMVP

          Multiply it with the scale:

           

          fScaleX=thisLayer.transform.scale[0];

          fScaleY=thisLayer.transform.scale[1];

          fWidth=thisLayer.width;

          fHeight=thisLayer.height;

           

          X=fWidth/2*fScaleX/100;

          Y=fHeight/2*fScaleY/100;

           

          [X,Y]

           

          Mylenium

          • 2. Re: The value of this expression
            Dan Ebberts Community Member

            I think you might need to do a layer space transform to get the center of the other layer into comp coordinates and then get that point into the coridnates of the layer with the expression. Like this:

             

            L = thisComp.layer("flower");

            fromComp(L.toComp([L.width/2, L.height/2]))

             

            Dan

            • 3. Re: The value of this expression
              Cris is Bliss Community Member

              Thank you, 

               

              I don't want to sound stupid, and I do want to learn more about using expression but I have no idea of how to use this--- do I place it before, after or in place of the   [thisLayer.width/2, thisLayer.height/2]   expression.   NO don't tell me.  This weekend when I have some extra time I will play around with it and try to figure it out myself.  If I don't get it to work I will let you know.

               

              Just looking at it I think it relates to the Scale property of the Layer that it is played in.  and it replaces the x,y values of the scale property with the width of the layer divided by 2 times the Scale divided by 100.  I just don't see what that "f" stands for.

               

              Thanks

              • 4. Re: The value of this expression
                Cris is Bliss Community Member

                Thank you for the feedback Dan,

                 

                Again as I said above, I don't want to sound stupid but.....

                 

                Just looking at it, I kind of understand what your expression is saying.  What I don't fully follow is your explanation.  I think you are saying--Do a layer space transform to get the center of the other layer's coordinates to read as if written in the Composition coordinates BECAUSE a layers coordinate is based upon the upper left corner of the layer where as the Comp's coordinates are based upon the upper left corner of the Comp and they are only the same when a layer is the exact same size as the Composition and placed in the center of Compsition.

                • 5. Re: The value of this expression
                  Dan Ebberts Community Member

                  That sounds right, but then you also need to convert from comp coordinates to coordinates for the layer with the expression. That's what fromComp() does. Of course, none of this is necessary if all layers are comp-sized, centered in the comp, not scaled or rotated, etc.

                   

                  Dan