RectKt

Added in 1.1.0

public final class RectKt


Summary

Public methods

static final @NonNull Rect
and(@NonNull Rect receiver, @NonNull Rect r)

Returns the intersection of two rectangles as a new rectangle.

static final @NonNull RectF
and(@NonNull RectF receiver, @NonNull RectF r)

Returns the intersection of two rectangles as a new rectangle.

static final int
component1(@NonNull Rect receiver)

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

static final float

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

static final int
component2(@NonNull Rect receiver)

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

static final float

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

static final int
component3(@NonNull Rect receiver)

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

static final float

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

static final int
component4(@NonNull Rect receiver)

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

static final float

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

static final boolean
contains(@NonNull Rect receiver, @NonNull Point p)

Returns true if the specified point is inside the rectangle.

static final boolean
contains(@NonNull RectF receiver, @NonNull PointF p)

Returns true if the specified point is inside the rectangle.

static final @NonNull Region
minus(@NonNull Rect receiver, @NonNull Rect r)

Returns the difference of this rectangle and the specified rectangle as a new region.

static final @NonNull Rect
minus(@NonNull Rect receiver, int xy)

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

static final @NonNull Rect
minus(@NonNull Rect receiver, @NonNull Point xy)

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

static final @NonNull Region
minus(@NonNull RectF receiver, @NonNull RectF r)

Returns the difference of this rectangle and the specified rectangle as a new region.

static final @NonNull RectF
minus(@NonNull RectF receiver, float xy)

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

static final @NonNull RectF
minus(@NonNull RectF receiver, @NonNull PointF xy)

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

static final @NonNull Rect
or(@NonNull Rect receiver, @NonNull Rect r)

Returns the union of two rectangles as a new rectangle.

static final @NonNull RectF
or(@NonNull RectF receiver, @NonNull RectF r)

Returns the union of two rectangles as a new rectangle.

static final @NonNull Rect
plus(@NonNull Rect receiver, @NonNull Rect r)

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

static final @NonNull Rect
plus(@NonNull Rect receiver, int xy)

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

static final @NonNull Rect
plus(@NonNull Rect receiver, @NonNull Point xy)

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

static final @NonNull RectF
plus(@NonNull RectF receiver, @NonNull RectF r)

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

static final @NonNull RectF
plus(@NonNull RectF receiver, float xy)

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

static final @NonNull RectF
plus(@NonNull RectF receiver, @NonNull PointF xy)

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

static final @NonNull Rect
times(@NonNull Rect receiver, int factor)

Returns a new rectangle representing this rectangle's components each scaled by factor.

static final @NonNull RectF
times(@NonNull RectF receiver, float factor)

Returns a new rectangle representing this rectangle's components each scaled by factor.

static final @NonNull RectF
times(@NonNull RectF receiver, int factor)

Returns a new rectangle representing this rectangle's components each scaled by factor.

static final @NonNull Rect
toRect(@NonNull RectF receiver)

Returns a Rect representation of this rectangle.

static final @NonNull RectF
toRectF(@NonNull Rect receiver)

Returns a RectF representation of this rectangle.

static final @NonNull Region
toRegion(@NonNull Rect receiver)

Returns a Region representation of this rectangle.

static final @NonNull Region
toRegion(@NonNull RectF receiver)

Returns a Region representation of this rectangle.

static final @NonNull RectF

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

static final @NonNull Region
xor(@NonNull Rect receiver, @NonNull Rect r)

Returns the union minus the intersection of two rectangles as a new region.

static final @NonNull Region
xor(@NonNull RectF receiver, @NonNull RectF r)

Returns the union minus the intersection of two rectangles as a new region.

Public methods

and

public static final @NonNull Rect and(@NonNull Rect receiver, @NonNull Rect r)

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.

and

public static final @NonNull RectF and(@NonNull RectF receiver, @NonNull RectF r)

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.

component1

public static final int component1(@NonNull Rect receiver)

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

This method allows to use destructuring declarations when working with rectangles, for example:

val (left, top, right, bottom) = myRectangle

component1

public static final float component1(@NonNull RectF receiver)

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

This method allows to use destructuring declarations when working with rectangles, for example:

val (left, top, right, bottom) = myRectangle

component2

public static final int component2(@NonNull Rect receiver)

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

This method allows to use destructuring declarations when working with rectangles, for example:

val (left, top, right, bottom) = myRectangle

component2

public static final float component2(@NonNull RectF receiver)

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

This method allows to use destructuring declarations when working with rectangles, for example:

val (left, top, right, bottom) = myRectangle

component3

public static final int component3(@NonNull Rect receiver)

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

This method allows to use destructuring declarations when working with rectangles, for example:

val (left, top, right, bottom) = myRectangle

component3

public static final float component3(@NonNull RectF receiver)

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

This method allows to use destructuring declarations when working with rectangles, for example:

val (left, top, right, bottom) = myRectangle

component4

public static final int component4(@NonNull Rect receiver)

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

This method allows to use destructuring declarations when working with rectangles, for example:

val (left, top, right, bottom) = myRectangle

component4

public static final float component4(@NonNull RectF receiver)

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

This method allows to use destructuring declarations when working with rectangles, for example:

val (left, top, right, bottom) = myRectangle

contains

public static final boolean contains(@NonNull Rect receiver, @NonNull Point p)

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.

contains

public static final boolean contains(@NonNull RectF receiver, @NonNull PointF p)

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

public static final @NonNull Region minus(@NonNull Rect receiver, @NonNull Rect r)

Returns the difference of this rectangle and the specified rectangle as a new region.

minus

public static final @NonNull Rect minus(@NonNull Rect receiver, int xy)

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

minus

public static final @NonNull Rect minus(@NonNull Rect receiver, @NonNull Point xy)

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

minus

public static final @NonNull Region minus(@NonNull RectF receiver, @NonNull RectF r)

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.

minus

public static final @NonNull RectF minus(@NonNull RectF receiver, float xy)

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

minus

public static final @NonNull RectF minus(@NonNull RectF receiver, @NonNull PointF xy)

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

or

public static final @NonNull Rect or(@NonNull Rect receiver, @NonNull Rect r)

Returns the union of two rectangles as a new rectangle.

or

public static final @NonNull RectF or(@NonNull RectF receiver, @NonNull RectF r)

Returns the union of two rectangles as a new rectangle.

plus

public static final @NonNull Rect plus(@NonNull Rect receiver, @NonNull Rect r)

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

plus

public static final @NonNull Rect plus(@NonNull Rect receiver, int xy)

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

plus

public static final @NonNull Rect plus(@NonNull Rect receiver, @NonNull Point xy)

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

plus

public static final @NonNull RectF plus(@NonNull RectF receiver, @NonNull RectF r)

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

plus

public static final @NonNull RectF plus(@NonNull RectF receiver, float xy)

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

plus

public static final @NonNull RectF plus(@NonNull RectF receiver, @NonNull PointF xy)

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

times

public static final @NonNull Rect times(@NonNull Rect receiver, int factor)

Returns a new rectangle representing this rectangle's components each scaled by factor.

times

public static final @NonNull RectF times(@NonNull RectF receiver, float factor)

Returns a new rectangle representing this rectangle's components each scaled by factor.

times

public static final @NonNull RectF times(@NonNull RectF receiver, int factor)

Returns a new rectangle representing this rectangle's components each scaled by factor.

toRect

public static final @NonNull Rect toRect(@NonNull RectF receiver)

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

toRectF

public static final @NonNull RectF toRectF(@NonNull Rect receiver)

Returns a RectF representation of this rectangle.

toRegion

public static final @NonNull Region toRegion(@NonNull Rect receiver)

Returns a Region representation of this rectangle.

toRegion

public static final @NonNull Region toRegion(@NonNull RectF receiver)

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

transform

public static final @NonNull RectF transform(@NonNull RectF receiver, @NonNull Matrix m)

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

xor

public static final @NonNull Region xor(@NonNull Rect receiver, @NonNull Rect r)

Returns the union minus the intersection of two rectangles as a new region.

xor

public static final @NonNull Region xor(@NonNull RectF receiver, @NonNull RectF r)

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