Accessing the position of simple shapes

73 Views Asked by At

I have a Rect assigned to a variable myrect:

var myrect = new Rect (250,0,20,200);

I thought that writing:

console.log(myrect.x);

would output 250 but, it says "undefined".

I would like to know how I can redraw this rectangle by performing arithmetic on its x and y coordinates.

1

There are 1 best solutions below

0
On BEST ANSWER

The way to access the x and y properties is through the attr() method.

console.log(myrect.attr('x'));

See it in the documentation. But I have to admit, the documentation isn't that beginner-friendly yet.