Rect
declare class Rect {}
Rect holds four integer coordinates for a rectangle. The rectangle is represented by the coordinates of its 4 edges (left, top, right bottom). These fields can be accessed directly. Use width() and height() to retrieve the rectangle's width and height. Note: most methods do not check to see that the coordinates are sorted correctly (i.e. left <= right and top <= bottom).
Note that the right and bottom coordinates are exclusive. This means a Rect being drawn untransformed onto a Canvas will draw into the column and row described by its left and top coordinates, but not those of its bottom and right.
Instance Method
isEmpty
Signature
declare class Rect {
isEmpty() : boolean
}
Description
Returns true if the rectangle is empty (left >= right or top >= bottom).
equals
Signature
declare class Rect {
equals(rect: Rect): boolean
}
Description
Indicates whether some other object is "equal to" this one.
height
Signature
declare class Rect {
height(): number
}
Description
Returns Rect height
width
Signature
declare class Rect {
width(): number
}
Description
Returns rect width
centerX
Signature
declare class Rect {
centerX(): number
}
Description
the horizontal center of the rectangle. If the computed value is fractional, this method returns the largest integer that is less than the computed value.
centerY
Signature
declare class Rect {
centerY(): number
}
Description
the vertical center of the rectangle. If the computed value is fractional, this method returns the largest integer that is less than the computed value.
exactCenterX
Signature
declare class Rect {
exactCenterX(): number
}
Description
the exact horizontal center of the rectangle as a float.
exactCenterY
Signature
declare class Rect {
exactCenterY(): number
}
Description
the exact vertical center of the rectangle as a float.
offset
Signature
declare class Rect {
offset(dx: number, dy: number): void
}
Description
Offset the rectangle by adding dx to its left and right coordinates, and adding dy to its top and bottom coordinates.
offsetTo
Signature
declare class Rect {
offsetTo(newLeft: number, newTop: number): void
}
Description
Offset the rectangle to a specific (left, top) position, keeping its width and height the same.
setEmpty
Signature
declare class Rect {
setEmpty(): void
}
Description
Set the rectangle to (0,0,0,0)
inset
Signature
declare class Rect {
inset(dx: number, dy: number): void
}
Description
Insets the rectangle on all sides specified by the insets.
contains
Signature
declare class Rect {
contains(rect: Rect): boolean
}
Description
Returns true iff the specified rectangle r is inside or equal to this rectangle.
contains
Signature
declare class Rect {
contains(x: number, y: number): boolean
}
Description
Returns true if (x,y) is inside the rectangle.
contains
Signature
declare class Rect {
contains(left: number, top: number, right: number, bottom: number)
}
Description
Returns true iff the 4 specified sides of a rectangle are inside or equal to this rectangle.