javascript - how can I position objects in raphael.js related to center -
when set x, y values objects position them on paper, measures x, y top left corner. there way change position related center middle of paper?
raphael has rectangles, circles, , ellipses.
- latter 2 positioned center coordinates, have nothing worry about.
- rectangle positioned based on top left corner coordinates
so answer question:
raphael not provide way position rectangle center coordinates.
however can easily.
@ demo.
for example:
// lets assume center coordinates cx , cy var rec = paper.rect(cx, cy, 120, 80); // position in middle, var rec = paper.rect(cx - 120/2, cy - 80/2, 120, 80);
it simple that. luck!
edit
if want in project, raphael.js , override rectangle class.
Comments
Post a Comment