C

MutableRectangle

Represents a mutable axis-aligned rectangle in two-dimensional Cartesian coordinates.

Remarks

This implementation delegates the storage to implementations of IMutablePoint for the upper left corner of the rectangle and IMutableSize for the size of the rectangle.

See Also

API

Rect, IRectangle

Members

Show:

Constructors

Creates a new empty instance located at the origin with width and height set to -1.
Creates a new instance initialized to the values of the provided argument.

Parameters

rectangle: IRectangle
The rectangle whose values are used to initialize the new instance.
Creates a new instance using the provided implementation for the storage of the position and size of the rectangle.
The instances provided will be referenced by this instance. This instance will be used as a live view over the provided instances. Changes to them will indirectly change the state of this instance and changes applied through this instance will be written to the referenced implementations.

Parameters

location: IMutablePoint
The provider for the dynamic position of this instance.
size: IMutableSize
The provider for the dynamic size of this instance.
Creates a new instance using the provided values to initialize the position and size.
An instance of MutablePoint will be used to store the position and an instance of dynamicSize will be used to store the size.

Parameters

location: Point
The coordinates of the upper left corner of the rectangle.
size: Size
The size of the rectangle.
Creates a new instance using the provided values to initialize the position and size.
An instance of MutablePoint will be used to store the position and an instance of dynamicSize will be used to store the size.

Parameters

x: number
The x-coordinate of the upper left corner of the rectangle.
y: number
The y-coordinate of the upper left corner of the rectangle.
width: number
The width of the rectangle.
height: number
The height of the rectangle.

Properties

Gets the coordinates of the bottom left corner of the rectangle as a Point.
readonly
Gets the coordinates of the bottom right corner of the rectangle as a Point.
readonly
Gets the coordinates of the center of the rectangle as a Point.
readonly
Gets the center x-coordinate of the rectangle.
readonly
Gets the center y-coordinate of the rectangle.
readonly
Gets the position of this rectangle.
This will return a live view of the position of this rectangle. However, setting a position instance will only copy the values of the point provided to the current position.
conversionfinal
Gets the size of this rectangle.
This will return a live view of the size of this rectangle. However, setting a size instance will only copy the values of the size provided to the current size.
conversionfinal
Gets or sets the height of this instance from the dynamicSize instance.
Note that depending on the implementation used for holding the size, the results may vary. However, the default implementation will do just that: read and write the values without modifying them in any way.
final
Determines whether the specified size is empty.
ISize instances are considered empty if their width or height is less than 0.0d.
readonly

Defined in

ISize.isEmpty
Gets the maximum x-coordinate of the rectangle.
This is the x-coordinate of the right side of the rectangle, or the left side if the rectangle is empty.
readonly

Defined in

IRectangle.maxX
Gets the maximum y-coordinate of the rectangle.
This is the y-coordinate of the bottom side of the rectangle, or the top side if the rectangle is empty.
readonly

Defined in

IRectangle.maxY
Gets the current size of the rectangle as Size.
readonly

Defined in

IRectangle.size
Gets the coordinates of the top left corner of the rectangle as a Point.
readonly
Gets the coordinates of the top right corner of the rectangle as a Point.
readonly
Gets or sets the width of this instance from the dynamicSize instance.
Note that depending on the implementation used for holding the size, the results may vary. However, the default implementation will do just that: read and write the values without modifying them in any way.
final
Gets or sets the x-coordinate of the upper left corner of this instance from the dynamicLocation instance.
Note that depending on the implementation used for holding the position, the results may vary. However, the default implementation will do just that: read and write the values without modifying them in any way.
final
Gets or sets the y-coordinate of the upper left corner of this instance from the dynamicLocation instance.
Note that depending on the implementation used for holding the position, the results may vary. However, the default implementation will do just that: read and write the values without modifying them in any way.
final

Methods

Adds a rectangle to another one.
The result is placed into the first rectangle, which is returned. If either of the two rectangles is empty, i.e. its width or height is negative, the result will be the other rectangle. If either of the two rectangles is infinite, i.e. its width or height is positive infinity, the result is an infinite rectangle.

Parameters

rectangle2: IRectangle
The rectangle to be added.
Adds a point to a rectangle, possibly enlarging the rectangle.

If the rectangle is initially empty, i.e. its width or height is negative, the bounds of the rectangle will be set to (x, y, 0, 0).

If either the x- or y-coordinate of the given point is infinite, this method has an undefined result.

Parameters

point: IPoint
The coordinate to include in the bounds.
Create a clone of this object.
final

Return Value

Object
A clone of this object.
Determines whether the given rectangle contains the provided point.

Parameters

point: IPoint
The point to test.
eps?: number
A positive value allows for fuzzy hit testing. If the point lies outside the given object but its distance is less than or equal to that value, it will be considered a hit.

Return Value

boolean
true iff the point lies inside the rectangle.
Determines whether the given rectangle contains the provided rectangle.

More formally, this rectangle contains the other rectangle if the coordinates of each point of the other rectangle are neither less than this rectangle's x and y minus eps nor greater than this rectangle's MaxX and MaxY plus eps.

Consequently, an empty rectangle neither contains any other rectangle nor is it contained in any other rectangle.

Note, the result of this method can be counterintuitive if this rectangle's x or y is positive or negative infinity.

Parameters

other: IRectangle
The rectangle to test.
eps?: number
A positive value allows for fuzzy hit testing.

Return Value

boolean
true if the given rectangle contains the provided rectangle, false otherwise.
Determines whether another object is equal to this one.
final

Parameters

other: any
the other object to compare for equality

Return Value

boolean
true if other is considered equal to this instance.
Returns a hash code for this object.

The hash code is a numeric value that can be used to treat this object as a key in a hash table or similar data structure.

Two objects that are considered equal must have the same hash code. However, the reverse does not hold and two objects having the same hash code don't have to be equal. Ideally, the hash code should be roughly uniformly-distributed to prevent hash tables from performing poorly. Calculating the hash code is also a potentially frequent operation and should therefore be fast.

final

Return Value

number
the hash code for this object
Sets the center of the rectangle to the provided value.
If the rectangle has either infinite width or infinite height, setting the center point has an undefined result.

Parameters

center: Point
The new center coordinates.
Applies a new position to a given mutable rectangle.

Parameters

location: IPoint
The new location.
Applies a new position to a given mutable rectangle.

Parameters

x: number
The new x-coordinate.
y: number
The new y-coordinate.
Applies a new position and size to a given mutable rectangle.

Parameters

newRectangle: IRectangle
The bounds to set for the rectangle.
Applies a new position and size to a given mutable rectangle.

Parameters

position: IPoint
The new location.
size: ISize
The new size.
Applies a new position and size to a given mutable rectangle.

Parameters

x: number
The new x-coordinate of the upper left corner of the rectangle.
y: number
The new y-coordinate of the upper left corner of the rectangle.
width: number
The new width of the rectangle.
height: number
The new height of the rectangle.
Sets the coordinates of the size to the given values.

Parameters

newSize: ISize
The new location.
Sets the coordinates of the size to the given values.

Parameters

newWidth: number
The new x-coordinate
newHeight: number
The new y-coordinate
Creates a Rect from a given MutableRectangle.
final

Return Value

Rect
The Rect.
Creates a new Size instance with the current values of this size.

Return Value

Size
A new Size instance that has been initialized with the current values of size.

Defined in

ISize.toSize
Returns a that describes this instance.
final

Return Value

string
A that describes this instance.

Static Methods

Performs an explicit conversion from Rect to MutableRectangle.
static

Parameters

rectangle: Rect
The rectangle to convert.

Return Value

MutableRectangle
The result of the conversion.
Performs an explicit conversion from MutableRectangle to Rect.
static

Parameters

rectangle: MutableRectangle
The rectangle to convert.

Return Value

Rect
The result of the conversion.