I tried to get from rect.cx and rect.cy from RaphaelJS.rect API. But I am getting undefined in the console.
I tried
var cx = rect.cx;
var cy = rect.cy;
and
console.info(rect.cx);
console.info(rect.cy);
all showing undefined.
how to get center coordinates from rectangle object.
The SVG rect element has neither a cx or cy, that is for circles. Also the code rect.x or rect.y would produce nothing anyways. You can always console.log() the element itself to see all of the available properties.
To get the center coords of a rect created with RaphaelJS you can do something like this:
If it were a regular SVG rect you could get these values using element.getAttribute("attribute-name")