1

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.

bruno
  • 2,213
  • 1
  • 19
  • 31
A1A2A3A4
  • 413
  • 1
  • 5
  • 11

1 Answers1

1

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.

Cristian
  • 5,877
  • 6
  • 46
  • 55