1     /**
2         A rectangle
3         @author <a href="mailto:matthewcasperson@gmail.com">Matthew Casperson</a>
4         @class
5     */
6     function Rectangle()
7 {
8 this.left = 0;
9 this.top = 0;
10 this.width = 0;
11 this.height = 0;
12 13 /** 14 Initialises the object 15 @param left Left position 16 @param top Top Position 17 @param width Width of rectangle 18 @param height Height of triangle 19 */ 20 this.startupRectangle = function(/**Number*/ left, /**Number*/ top, /**Number*/ width, /**Number*/ height)
21 {
22 this.left = left;
23 this.top = top;
24 this.width = width;
25 this.height = height;
26 return this;
27 }
28 29 /** 30 @return true if there is an intersection, false otherwise 31 @param other The other rectangle to test against 32 */ 33 this.intersects = function(/**Rectangle*/ other)
34 {
35 if (this.left + this.width < other.left)
36 return false;
37 if (this.top + this.height < other.top)
38 return false;
39 if (this.left > other.left + other.width)
40 return false;
41 if (this.top > other.top + other.height)
42 return false;
43 44 return true;
45 }
46 }
Top