MutableRect


An mutable, 2D, axis-aligned, floating-point rectangle whose coordinates are relative to a given origin.

Summary

Public constructors

MutableRect(left: Float, top: Float, right: Float, bottom: Float)
Cmn

Public functions

operator Boolean
contains(offset: 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.

Cmn
Unit
deflate(delta: Float)

Moves edges inwards by the given delta.

Cmn
Unit
inflate(delta: Float)

Moves edges outwards by the given delta.

Cmn
Unit
intersect(left: Float, top: Float, right: Float, bottom: Float)

Modifies this to be the intersection of this and the rect formed by left, top, right, and bottom.

Cmn
Boolean

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

Cmn
Boolean
overlaps(other: Rect)

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

Cmn
Unit
set(left: Float, top: Float, right: Float, bottom: Float)

Sets new bounds to (left, top, right, bottom)

Cmn
open String
Cmn
Unit
translate(offset: Offset)

Translates the rect by the provided Offset.

Cmn
Unit
translate(translateX: Float, translateY: Float)

Updates this rectangle with translateX added to the x components and translateY added to the y components.

Cmn

Public properties

Float

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

Cmn
Offset

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

Cmn
Offset

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

Cmn
Offset

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

Cmn
Offset

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

Cmn
Offset

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

Cmn
Offset

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

Cmn
Float

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

Cmn
Boolean

Whether this rectangle encloses a non-zero area.

Cmn
Boolean

Whether all coordinates of this rectangle are finite.

Cmn
Boolean

Whether any of the coordinates of this rectangle are equal to positive infinity.

Cmn
Float

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

Cmn
Float

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

Cmn
Float

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

Cmn
Float

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

Cmn
Size

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

Cmn
Float

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

Cmn
Offset

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

Cmn
Offset

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

Cmn
Offset

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

Cmn
Float

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

Cmn

Extension functions

Rect
Cmn

Public constructors

MutableRect

MutableRect(left: Float, top: Float, right: Float, bottom: Float)
Parameters
left: Float

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

top: Float

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

right: Float

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

bottom: Float

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

Public functions

contains

operator 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): Unit

Moves edges inwards by the given delta.

inflate

fun inflate(delta: Float): Unit

Moves edges outwards by the given delta.

intersect

fun intersect(left: Float, top: Float, right: Float, bottom: Float): Unit

Modifies this to be the intersection of this and the rect formed by left, top, right, and bottom.

overlaps

fun overlaps(other: MutableRect): Boolean

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

overlaps

fun overlaps(other: Rect): Boolean

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

set

fun set(left: Float, top: Float, right: Float, bottom: Float): Unit

Sets new bounds to (left, top, right, bottom)

toString

open fun toString(): String

translate

fun translate(offset: Offset): Unit

Translates the rect by the provided Offset.

translate

fun translate(translateX: Float, translateY: Float): Unit

Updates this rectangle with translateX added to the x components and translateY added to the y components.

Public properties

bottom

var bottom: Float

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

bottomCenter

val bottomCenter: Offset

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

bottomLeft

val bottomLeft: Offset

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

bottomRight

val bottomRight: Offset

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

center

val center: 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.

centerLeft

val centerLeft: Offset

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

centerRight

val centerRight: Offset

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

height

val height: Float

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

isEmpty

val isEmpty: Boolean

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

isFinite

val isFinite: Boolean

Whether all coordinates of this rectangle are finite.

isInfinite

val isInfinite: Boolean

Whether any of the coordinates of this rectangle are equal to positive infinity.

left

var left: Float

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

maxDimension

val maxDimension: Float

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

minDimension

val minDimension: Float

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

right

var right: Float

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

size

val size: Size

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

top

var top: Float

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

topCenter

val topCenter: Offset

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

topLeft

val topLeft: Offset

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

topRight

val topRight: Offset

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

width

val width: Float

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

Extension functions

MutableRect.toRect

fun MutableRect.toRect(): Rect