Rect
data class Rect
kotlin.Any  
↳  androidx.ui.engine.geometry.Rect 
An immutable, 2D, axisaligned, floatingpoint rectangle whose coordinates are relative to a given origin.
A Rect can be created with one its constructors or from an Offset and a
Size using the &
operator:
Rect myRect = const Offset(1.0, 2.0) & const Size(3.0, 4.0);
Summary
Public constructors 


An immutable, 2D, axisaligned, floatingpoint rectangle whose coordinates are relative to a given origin. 
Public methods 


Boolean 
Whether the point specified by the given offset (which is assumed to be relative to the origin) lies between the left and right and the top and bottom edges of this rectangle. 
Rect 
Returns a new rectangle with edges moved inwards by the given delta. 
Rect 
expandToInclude(other: Rect) Returns a new rectangle which is the bounding box containing this rectangle and the given rectangle. 
Offset 
The offset to the center of the bottom edge of this rectangle. 
Offset 
The offset to the intersection of the bottom and left edges of this rectangle. 
Offset 
The offset to the intersection of the bottom and right edges of this rectangle. 
Offset 
The offset to the point halfway between the left and right and the top and bottom edges of this rectangle. 
Offset 
The offset to the center of the left edge of this rectangle. 
Offset 
The offset to the center of the right edge of this rectangle. 
Float 
The greater of the magnitudes of the width and the height of this rectangle. 
Float 
The lesser of the magnitudes of the width and the height of this rectangle. 
Size 
getSize() The distance between the upperleft corner and the lowerright corner of this rectangle. 
Offset 
The offset to the center of the top edge of this rectangle. 
Offset 
The offset to the intersection of the top and left edges of this rectangle. 
Offset 
The offset to the intersection of the top and right edges of this rectangle. 
Rect 
Returns a new rectangle with edges moved outwards by the given delta. 
Rect 
Returns a new rectangle that is the intersection of the given rectangle and this rectangle. 
Boolean 
isEmpty() Whether this rectangle encloses a nonzero area. 
Boolean 
isFinite() Whether all coordinates of this rectangle are finite. 
Boolean 
Whether any of the coordinates of this rectangle are equal to positive infinity. 
Rect  
Boolean 
Whether 
Rect 
Returns a new rectangle translated by the given offset. 
String 
toString() 
Rect 
Returns a new rectangle with translateX added to the x components and translateY added to the y components. 
Companion functions 


Rect 
fromCircle(center: Offset, radius: Float) Construct a rectangle that bounds the given circle. 
Rect 
Construct a rectangle from its left, top, right, and bottom edges. 
Rect 
Construct a rectangle from its left and top edges, its width, and its height. 
Rect 
fromPoints(a: Offset, b: Offset) Construct the smallest rectangle that encloses the given offsets, treating them as vectors from the origin. 
Extension functions 


From androidx.ui.core

Properties 


Float  
Float 
The distance between the top and bottom edges of this rectangle. 
Float  
Float  
Float  
Float 
The distance between the left and right edges of this rectangle. 
Companion properties 


Float  
Rect 
A rectangle that covers the entire coordinate space. 
Rect 
A rectangle with left, top, right, and bottom edges all at zero. 
Public constructors
<init>
Rect(
left: Float,
top: Float,
right: Float,
bottom: Float)
An immutable, 2D, axisaligned, floatingpoint rectangle whose coordinates are relative to a given origin.
A Rect can be created with one its constructors or from an Offset and a
Size using the &
operator:
Rect myRect = const Offset(1.0, 2.0) & const Size(3.0, 4.0);
Public methods
contains
fun contains(offset: Offset): Boolean
Whether the point specified by the given offset (which is assumed to be relative to the origin) lies between the left and right and the top and bottom edges of this rectangle.
Rectangles include their top and left edges but exclude their bottom and right edges.
deflate
fun deflate(delta: Float): Rect
Returns a new rectangle with edges moved inwards by the given delta.
expandToInclude
fun expandToInclude(other: Rect): Rect
Returns a new rectangle which is the bounding box containing this rectangle and the given rectangle.
getBottomCenter
fun getBottomCenter(): Offset
The offset to the center of the bottom edge of this rectangle.
See also Size.bottomLeft.
getBottomLeft
fun getBottomLeft(): Offset
The offset to the intersection of the bottom and left edges of this rectangle.
See also Size.bottomLeft.
getBottomRight
fun getBottomRight(): Offset
The offset to the intersection of the bottom and right edges of this rectangle.
See also Size.bottomRight.
getCenter
fun getCenter(): Offset
The offset to the point halfway between the left and right and the top and bottom edges of this rectangle.
See also Size.center.
getCenterLeft
fun getCenterLeft(): Offset
The offset to the center of the left edge of this rectangle.
See also Size.centerLeft.
getCenterRight
fun getCenterRight(): Offset
The offset to the center of the right edge of this rectangle.
See also Size.centerLeft.
getLongestSide
fun getLongestSide(): Float
The greater of the magnitudes of the width and the height of this rectangle.
getShortestSide
fun getShortestSide(): Float
The lesser of the magnitudes of the width and the height of this rectangle.
getSize
fun getSize(): Size
The distance between the upperleft corner and the lowerright corner of this rectangle.
getTopCenter
fun getTopCenter(): Offset
The offset to the center of the top edge of this rectangle.
See also Size.topCenter.
getTopLeft
fun getTopLeft(): Offset
The offset to the intersection of the top and left edges of this rectangle.
See also Size.topLeft.
getTopRight
fun getTopRight(): Offset
The offset to the intersection of the top and right edges of this rectangle.
See also Size.topRight.
inflate
fun inflate(delta: Float): Rect
Returns a new rectangle with edges moved outwards by the given delta.
intersect
fun intersect(other: Rect): Rect
Returns a new rectangle that is the intersection of the given rectangle and this rectangle. The two rectangles must overlap for this to be meaningful. If the two rectangles do not overlap, then the resulting Rect will have a negative width or height.
isEmpty
fun isEmpty(): Boolean
Whether this rectangle encloses a nonzero area. Negative areas are considered empty.
isInfinite
fun isInfinite(): Boolean
Whether any of the coordinates of this rectangle are equal to positive infinity.
overlaps
fun overlaps(other: Rect): Boolean
Whether other
has a nonzero area of overlap with this rectangle.
shift
fun shift(offset: Offset): Rect
Returns a new rectangle translated by the given offset.
To translate a rectangle by separate x and y components rather than by an Offset, consider translate.
toString
fun toString(): String
translate
fun translate(
translateX: Float,
translateY: Float
): Rect
Returns a new rectangle with translateX added to the x components and translateY added to the y components.
To translate a rectangle by an Offset rather than by separate x and y components, consider shift.
Properties
bottom
val bottom: Float
left
val left: Float
right
val right: Float
top
val top: Float
Companion functions
fromCircle
fun fromCircle(
center: Offset,
radius: Float
): Rect
Construct a rectangle that bounds the given circle.
The center
argument is assumed to be an offset from the origin.
fromLTRB
fun fromLTRB(
left: Float,
top: Float,
right: Float,
bottom: Float
): Rect
Construct a rectangle from its left, top, right, and bottom edges.
fromLTWH
fun fromLTWH(
left: Float,
top: Float,
width: Float,
height: Float
): Rect
Construct a rectangle from its left and top edges, its width, and its height.
To construct a Rect from an Offset and a Size, you can use the
rectangle constructor operator &
. See Offset.&.
fromPoints
fun fromPoints(
a: Offset,
b: Offset
): Rect
Construct the smallest rectangle that encloses the given offsets, treating them as vectors from the origin.
Companion properties
_giantScalar
val _giantScalar: Float
largest
val largest: Rect
A rectangle that covers the entire coordinate space.
This covers the space from 1e7,1e7 to 1e7, 1e7. This is the space over which graphics operations are valid.