Quantcast
Channel: Adobe Community : Discussion List - After Effects Scripting
Viewing all articles
Browse latest Browse all 2143

Calculate shape center

$
0
0

Hello! Help me please. I trying to calculate center of shape layer. Now i have this code:

  1.     function CalculateShapeCenter(shapeLayer)
  2.     {
  3.         var rect = shapeLayer.sourceRectAtTime(0,true);
  4.         var pos = shapeLayer.transform.position.value;
  5.         var anchor = shapeLayer.transform.anchorPoint.value;
  6.         var scale = shapeLayer.transform.scale.value;
  7.         var sx = scale[0]/100;
  8.         var sy = scale[1]/100;
  9.         return pos-anchor + [rect.left*sx, rect.top*sy] + [(rect.width*sx)/2, (rect.height*sy)/2];
  10.     }

 

It works, but it works only if i don't move anchor point of shape layer. If i align anchor before call this funсtion - wrong result, but if anchor don't touched - i have correct result. Tell me what I'm missing in this calculation?


Viewing all articles
Browse latest Browse all 2143

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>