core-ktx / androidx.graphics / android.graphics.RectF

Extensions for android.graphics.RectF

and

infix fun RectF.and(r: RectF): RectF

Returns the union of two rectangles as a new rectangle.

component1

operator fun RectF.component1(): Float

Returns "left", the first component of the rectangle.

component2

operator fun RectF.component2(): Float

Returns "top", the second component of the rectangle.

component3

operator fun RectF.component3(): Float

Returns "right", the third component of the rectangle.

component4

operator fun RectF.component4(): Float

Returns "bottom", the fourth component of the rectangle.

contains

operator fun RectF.contains(p: PointF): Boolean

Returns true if the specified point is inside the rectangle. The left and top are considered to be inside, while the right and bottom are not. This means that for a point to be contained: left <= x < right and top <= y < bottom. An empty rectangle never contains any point.

minus

operator fun RectF.minus(r: RectF): Region

Returns the difference of this rectangle and the specified rectangle as a new region. This rectangle is first converted to a Rect using RectF.toRect.

operator fun RectF.minus(xy: Float): RectF

Returns a new rectangle representing this rectangle offset by the negation of the specified amount on both X and Y axis.

operator fun RectF.minus(xy: PointF): RectF

Returns a new rectangle representing this rectangle offset by the negation of the specified point.

or

infix fun RectF.or(r: RectF): RectF

Returns the intersection of two rectangles as a new rectangle. If the rectangles do not intersect, returns a copy of the left hand side rectangle.

plus

operator fun RectF.plus(r: RectF): RectF

Performs the union of this rectangle and the specified rectangle and returns the result as a new rectangle.

operator fun RectF.plus(xy: Float): RectF

Returns a new rectangle representing this rectangle offset by the specified amount on both X and Y axis.

operator fun RectF.plus(xy: PointF): RectF

Returns a new rectangle representing this rectangle offset by the specified point.

toRect

fun RectF.toRect(): Rect

Returns a Rect representation of this rectangle. The resulting rect will be sized such that this rect can fit within it.

toRegion

fun RectF.toRegion(): Region

Returns a Region representation of this rectangle. The resulting rect will be sized such that this rect can fit within it.

transform

fun RectF.transform(m: Matrix): RectF

Transform this rectangle in place using the supplied Matrix and returns this rectangle.

xor

infix fun RectF.xor(r: RectF): Region

Returns the union minus the intersection of two rectangles as a new region. The two rectangles are first converted to Rect using RectF.toRect.