Script Reference : Rect
A Rect object stores the upper-left and lower-right corners of a rectangle. This is just a cordinates of rectange, there is no relation to content on the page.
| Name | Type | Description |
|---|---|---|
| left | float | Specifies the x-coordinate of the upper-left corner of the rectangle. |
| top | float | Specifies the y-coordinate of the upper-left corner of the rectangle. |
| right | float | Specifies the x-coordinate of the lower-right corner of the rectangle. |
| bottom | float | Specifies the y-coordinate of the lower-right corner of the rectangle. |
| Name | Description |
|---|---|
| Rect::Rect() | Creates a Rect object whose left,top,bottom,right coordinates are all zero. This is the default constructor. |
| Rect::Rect(Rect) | Creates a new Rect object and copies the data members from another Rect object. |
| Rect::Rect(Point leftTop, Point rigthBottom) | Creates a new Rect object using left top and right bottom coordinates. |
| Rect::Rect(float left, float top, float right, float bottom) | Creates a new Rect object using left, top, bottom, right coordinates. |
| Name | Return Type | Description |
|---|---|---|
| bool Contains(Rect) bool Contains(Point) bool Contains(float x,float y) |
bool | The Contains method determines whether another rectangle or point is inside this rectangle. |
| bool Intersect(Rect) | bool | If the intersection of the two rectangles is not empty, this method returns true; otherwise, it returns false. |
| void Offset(Point) void Offset(float x,float y) |
void | The Offset method moves this rectangle horizontally and vertically. |
| void Inflate(Point) void Inflate(float x,float y) |
void | The Inflate method expands the rectangle by the value of X on the left and right edges, and by the value of Y on the top and bottom edges. |
| Point Center() | Point | Returns center of this rectangle. |
| Point Size() | Point | The GetSize method gets the width and height of the rectangle. |
| void Normalize() | void | Normalizes rectangle by swapping left and right in case if left is greater than right. Same with ot top and bottom. |
| += Rect += Point Rect + Rect |
Operators enlarge this rectangle in case if specified area or point is outside of this rectangle. | |
| bool IsEmpty() | bool | The IsEmpty method determines whether this rectangle is empty. |
| float Width() | float | Width of rectangle |
| float Height() | float | Height of rectangle |
Sample:
local r=Rect(0,0,100,200);
local p=Point(-1,-2);
r+=p;
MsgBox("Rect: "+ r.left.tostring()+", "+r.top.tostring()+", "+r.right.tostring()+", "+r.bottom.tostring());
local p=Point(-1,-2);
r+=p;
MsgBox("Rect: "+ r.left.tostring()+", "+r.top.tostring()+", "+r.right.tostring()+", "+r.bottom.tostring());
