{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

IntRect

public final class IntRect


An immutable, 2D, axis-aligned, integer bounds rectangle whose coordinates are relative to a given origin.

Summary

Nested types

public static class IntRect.Companion

Public constructors

IntRect(int left, int top, int right, int bottom)

Public methods

final 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.

final @NonNull IntRect
deflate(int delta)

Returns a new rectangle with edges moved inwards by the given delta.

final int

The offset of the bottom edge of this rectangle from the y axis.

final @NonNull IntOffset

The offset to the center of the bottom edge of this rectangle.

final @NonNull IntOffset

The offset to the intersection of the bottom and left edges of this rectangle.

final @NonNull IntOffset

The offset to the intersection of the bottom and right edges of this rectangle.

final @NonNull IntOffset

The offset to the point halfway between the left and right and the top and bottom edges of this rectangle.

final @NonNull IntOffset

The offset to the center of the left edge of this rectangle.

final @NonNull IntOffset

The offset to the center of the right edge of this rectangle.

final int

The distance between the top and bottom edges of this rectangle.

final int

The offset of the left edge of this rectangle from the x axis.

final int

The greater of the magnitudes of the width and the height of this rectangle.

final int

The lesser of the magnitudes of the width and the height of this rectangle.

final int

The offset of the right edge of this rectangle from the x axis.

final @NonNull IntSize

The distance between the upper-left corner and the lower-right corner of this rectangle.

final int

The offset of the top edge of this rectangle from the y axis.

final @NonNull IntOffset

The offset to the center of the top edge of this rectangle.

final @NonNull IntOffset

The offset to the intersection of the top and left edges of this rectangle.

final @NonNull IntOffset

The offset to the intersection of the top and right edges of this rectangle.

final int

The distance between the left and right edges of this rectangle.

final @NonNull IntRect
inflate(int delta)

Returns a new rectangle with edges moved outwards by the given delta.

final @NonNull IntRect

Returns a new rectangle that is the intersection of the given rectangle and this rectangle.

final boolean

Whether this rectangle encloses a non-zero area.

final boolean

Whether other has a nonzero area of overlap with this rectangle.

@NonNull String
final @NonNull IntRect

Returns a new rectangle translated by the given offset.

final @NonNull IntRect
translate(int translateX, int translateY)

Returns a new rectangle with translateX added to the x components and translateY added to the y components.

Extension functions

final @NonNull Rect

Converts an IntRect to a Rect

final @NonNull Rect

Creates a new instance of android.graphics.Rect with the same bounds specified in the given IntRect

Public constructors

IntRect

public IntRect(int left, int top, int right, int bottom)

Public methods

contains

public final boolean contains(@NonNull IntOffset offset)

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

public final @NonNull IntRect deflate(int delta)

Returns a new rectangle with edges moved inwards by the given delta.

getBottom

public final int getBottom()

The offset of the bottom edge of this rectangle from the y axis.

getBottomCenter

public final @NonNull IntOffset getBottomCenter()

The offset to the center of the bottom edge of this rectangle.

getBottomLeft

public final @NonNull IntOffset getBottomLeft()

The offset to the intersection of the bottom and left edges of this rectangle.

getBottomRight

public final @NonNull IntOffset getBottomRight()

The offset to the intersection of the bottom and right edges of this rectangle.

getCenter

public final @NonNull IntOffset getCenter()

The offset to the point halfway between the left and right and the top and bottom edges of this rectangle.

See also IntSize.center.

getCenterLeft

public final @NonNull IntOffset getCenterLeft()

The offset to the center of the left edge of this rectangle.

getCenterRight

public final @NonNull IntOffset getCenterRight()

The offset to the center of the right edge of this rectangle.

getHeight

public final int getHeight()

The distance between the top and bottom edges of this rectangle.

getLeft

public final int getLeft()

The offset of the left edge of this rectangle from the x axis.

getMaxDimension

public final int getMaxDimension()

The greater of the magnitudes of the width and the height of this rectangle.

getMinDimension

public final int getMinDimension()

The lesser of the magnitudes of the width and the height of this rectangle.

getRight

public final int getRight()

The offset of the right edge of this rectangle from the x axis.

getSize

public final @NonNull IntSize getSize()

The distance between the upper-left corner and the lower-right corner of this rectangle.

getTop

public final int getTop()

The offset of the top edge of this rectangle from the y axis.

getTopCenter

public final @NonNull IntOffset getTopCenter()

The offset to the center of the top edge of this rectangle.

getTopLeft

public final @NonNull IntOffset getTopLeft()

The offset to the intersection of the top and left edges of this rectangle.

getTopRight

public final @NonNull IntOffset getTopRight()

The offset to the intersection of the top and right edges of this rectangle.

getWidth

public final int getWidth()

The distance between the left and right edges of this rectangle.

inflate

public final @NonNull IntRect inflate(int delta)

Returns a new rectangle with edges moved outwards by the given delta.

intersect

public final @NonNull IntRect intersect(@NonNull IntRect other)

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 IntRect will have a negative width or height.

isEmpty

public final boolean isEmpty()

Whether this rectangle encloses a non-zero area. Negative areas are considered empty.

overlaps

public final boolean overlaps(@NonNull IntRect other)

Whether other has a nonzero area of overlap with this rectangle.

toString

public @NonNull String toString()

translate

public final @NonNull IntRect translate(@NonNull IntOffset offset)

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.

translate

public final @NonNull IntRect translate(int translateX, int translateY)

Returns a new rectangle with translateX added to the x components and translateY added to the y components.

Extension functions

IntRectKt.toRect

public final @NonNull Rect IntRectKt.toRect(@NonNull IntRect receiver)

Converts an IntRect to a Rect

RectHelperKt.toAndroidRect

public final @NonNull Rect RectHelperKt.toAndroidRect(@NonNull IntRect receiver)

Creates a new instance of android.graphics.Rect with the same bounds specified in the given IntRect