Rect class
Class for representing rectangular regions. @param {number} x Left. @param {number} y Top. @param {number} w Width. @param {number} h Height. @struct @constructor
Properties
Methods
-
boundingBoxPreservingAspectRatioXmidYmid(
Box box, Rect rect) → void - Box is interpreted as a proportion, with 100 being the highest unit value.
-
boundingRect(
Rect rect) → void - Expand this rectangle to also include the area of the given rectangle. @param {goog.math.Rect} rect The other rectangle.
-
contains(
Rect another) → bool - Tests whether this rectangle entirely contains another rectangle.
-
containsPoint(
Coordinate point) → bool - Tests whether this rectangle entirely contains coordinate.
-
copy(
) → Rect - @return {!goog.math.Rect} A new copy of this Rectangle.
-
distance(
Coordinate point) → double - @param {!goog.math.Coordinate} point A coordinate. @return {number} The distance between the point and the closest point inside the rectangle. Returns 0 if the point is inside the rectangle.
-
fitInto(
Rect rect) → void - Fit this rectangle into the other rectangle by resizing it
-
getBottom(
) → double - Returns bottom computeed value.
-
getBottomCentre(
) → Coordinate - Gets bottom centre
-
getBottomLeft(
) → Coordinate - @return {!goog.math.Coordinate} A new coordinate for the bottom-left corner of the rectangle.
-
getBottomRight(
) → Coordinate - @return {!goog.math.Coordinate} A new coordinate for the bottom-right corner of the rectangle.
-
getCentre(
) → Coordinate - @return {!goog.math.Coordinate} A new coordinate for the center of the rectangle.
-
getEdge(
CardinalDirectionType edge) → RectEdge - Get point from edge of rect
-
getLeftCentre(
) → Coordinate - Gets left centre
-
getRight(
) → double - Returns right computeed value.
-
getRightCentre(
) → Coordinate - Gets right centre
-
getTopCentre(
) → Coordinate - Gets top centre
-
getTopLeft(
) → Coordinate - @return {!goog.math.Coordinate} A new coordinate for the top-left corner of the rectangle.
-
getTopRight(
) → Coordinate - @return {!goog.math.Coordinate} A new coordinate for the top-right corner of the rectangle.
-
intersection(
Rect rect) → bool - Computes the intersection of this rectangle and the rectangle parameter. If there is no intersection, returns false and leaves this rectangle as is. @param {goog.math.Rect} rect A Rectangle. @return {bool} True iff this rectangle intersects with the parameter.
-
intersects(
Rect rect) → bool - Returns whether a rectangle intersects this rectangle. @param {goog.math.Rect} rect A rectangle. @return {bool} Whether rect intersects this rectangle.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
scale(
double sx, double sy) → void - Scales this rectangle by the given scale factors. The left and width values are scaled by {@code sx} and the top and height values are scaled by {@code opt_sy}. If {@code opt_sy} is not given, then all fields are scaled by {@code sx}. @param {number} sx The scale factor to use for the x dimension. @param {number=} opt_sy The scale factor to use for the y dimension. @return {!goog.math.Rect} This rectangle after scaling.
-
setBottom(
double value) → void - Sets bottom
-
setBottomLeft(
Coordinate point) → void - Sets bottom left.
-
setBottomRight(
Coordinate point) → void - Sets bottom right.
-
setCenter(
Coordinate point) → void - Sets center of this Rect to be at this center point.
-
setRight(
double value) → void - Sets right
-
setSize(
Size size) → void - Set Rect width and height from Size object.
-
setTopLeft(
Coordinate point) → void - Sets top left.
-
setTopLeftAndBottomRight(
Coordinate point1, Coordinate point2) → void - The order of the input parameters does not matter, coordinates are sorted based on comparison.
-
setTopRight(
Coordinate point) → void - Sets top right.
-
squaredDistance(
Coordinate point) → double - @param {!goog.math.Coordinate} point A coordinate. @return {number} The squared distance between the point and the closest point inside the rectangle. Returns 0 if the point is inside the rectangle.
-
toSize(
) → Size -
toString(
) → String -
Returns a nice string representing size and dimensions of rectangle.
@return {string} In the form (50, 73 - 75w x 25h).
@override
override
-
translate(
Coordinate tx) → Rect - Translates this rectangle by the given offsets. If a {@code goog.math.Coordinate} is given, then the left and top values are translated by the coordinate's x and y values. Otherwise, top and left are translated by {@code tx} and {@code opt_ty} respectively. @param {number|goog.math.Coordinate} tx The value to translate left by or the the coordinate to translate this rect by. @param {number=} opt_ty The value to translate top by. @return {!goog.math.Rect} This rectangle after translating.
-
translateRelativeToCoordinate(
Coordinate point) → Rect - Translate rect so it is relative to a coordinate
-
translateRelativeToRect(
Rect otherRect) → Rect - Translate rect so it is relative to the top-left position (goes inside of) another rect.
Operators
-
operator ==(
Object other) → bool -
Compares rectangles for equality.
@param {goog.math.Rect} a A Rectangle.
@param {goog.math.Rect} b A Rectangle.
@return {bool} True iff the rectangles have the same left, top, width,
and height, or if both are null.
override
Static Methods
-
intersectsFrom(
Rect a, Rect b) → bool - Returns whether two rectangles intersect. Two rectangles intersect if they touch at all, for example, two zero width and height rectangles would intersect if they had the same top and left. @param {goog.math.Rect} a A Rectangle. @param {goog.math.Rect} b A Rectangle. @return {bool} Whether a and b intersect.