1 Reply Latest reply on Apr 15, 2013 1:09 PM by resdesign

Hi to everyone!

How can i change the registry point of and object?

I dont mean the pivot, i mean the "registry point".

When i want to center an object to the perfect center, if i put 50%, this count since the upper left corner, and adds all the height and width of the same object. I want to count since the center of the object.

How can i do this? Somebody can help me, please? Thnx a lot.

• ###### 1. Re: About the "Registry point"?

since any div is a rectangle or a square I suppose you can calculate the coordinate of the center like this:

the x axis would be at 1/2 width

and the y axis at 1/2 height.

var xAxis = 400/2;

var yAxis = 300/2;

so the registry point would be at (xAxis, yAxis)

Therefore if you wanted to center the element  400 x 300 according to a stage that is 500 x 400 and the center point you could use this:

var xAxis = 400/2;

var yAxis = 300/2;

var xPos = (500/2 - xAxis);

var yPos = (400/2 - yAxis);

sym.\$('Rectangle').css({

left: xPos,

top: yPos

});

You could generalize this by getting the height of the stage and the height of your element as well as the width of your stage and the owidth of your element and apply the formula.

var elementHeight = sym.\$('Rectangle').height();

var elementWidth = sym.\$('Rectangle').width();

var stageHeight = sym.\$('Stage').height();

var stageWidth = sym.\$('Stage').width();

sym.\$('Rectangle').css({

'left': stageWidth/2-elementWidth/2,

'top': stageHeight/2-elementHeight/2

});

Here is the file with 2 different elements, a rectangle and an ellipse being centered on the stage according to their registration point which is in this case the middle of the element.

https://www.box.com/s/79oh194blyk45wjcvw74

If you wanted to center the element according to its origin, then it would be different.

Hope this helps.