A1A2A3A4
A1A2A3A4

Reputation: 453

Accessing the position of simple shapes

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.

Upvotes: 1

Views: 72

Answers (1)

Cristian
Cristian

Reputation: 6085

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.

Upvotes: 1

Related Questions