Search code examples
javascriptadobe-indesignextendscriptadobe-extension

CEP/JavaScript : How to get the center of a circle?


I create a circle with this method:

var yMinCir = height - 1515.80/2.667+8.5;
var yMaxCir = height - 1545.80/2.667+8.5;
var myCircle = page.ovals.add({geometricBounds:[yMinCir, 1312.63/2.667+8.5, yMaxCir, 1342.63/2.667+8.5]});

Is there a way to recover the center by doing for example :

var centerOfMyCircle = myCircle.center;

Or does it have to be calculated ? If yes, how ?

I searched everywhere but I did not find anything..

Thank you in advance for your help !


Solution

  • You can get the geometricBounds of the object (the same you are setting). Then the center of your circle will be

    var gb = myCircle.geometricBounds;
    var centery = (gb[2] - gb[0]) / 2;
    var centerx = (gb[3] - gb[1]) / 2;