Mellon
Mellon

Reputation: 38842

Raphael js, how to get a circle's center x, y position?

If I have a circle object

var c = paper.circle(...)

I would like to get this circle's center x, y position, how to get?

Upvotes: 2

Views: 6827

Answers (2)

user56725
user56725

Reputation:

Do something like:

var c = paper.circle(...);
var centerX = c.attr('x') + c.attr('width') / 2;
var centerY = c.attr('y') + c.attr('height') / 2;

Upvotes: 1

David Tang
David Tang

Reputation: 93674

You can get the SVG attributes of cx and cy with:

c.attr('cx');

Upvotes: 11

Related Questions