The Android Developer Challenge is back! Submit your idea before December 2.

androidx.ui.engine.geometry

Classes

Offset

An immutable 2D floating-point offset.

Outline

Defines a simple shape, used for bounding graphical regions.

Radius

A radius for either circular or elliptical shapes.

Rect

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

RRect

An immutable rounded rectangle with custom radii for all four corners.

Size

Holds a 2D floating-point size.

Top-level functions summary

RRect
RRect(left: Float, top: Float, right: Float, bottom: Float, radiusX: Float, radiusY: Float)

Construct a rounded rectangle from its left, top, right, and bottom edges, and the same radii along its horizontal axis and its vertical axis.

RRect
RRect(left: Float, top: Float, right: Float, bottom: Float, radius: Radius)

Construct a rounded rectangle from its left, top, right, and bottom edges, and the same radius in each corner.

RRect
RRect(rect: Rect, radiusX: Float, radiusY: Float)

Construct a rounded rectangle from its bounding box and the same radii along its horizontal axis and its vertical axis.

RRect
RRect(rect: Rect, radius: Radius)

Construct a rounded rectangle from its bounding box and a radius that is the same in each corner.

RRect
RRect(left: Float, top: Float, right: Float, bottom: Float, topLeft: Radius = Radius.zero, topRight: Radius = Radius.zero, bottomRight: Radius = Radius.zero, bottomLeft: Radius = Radius.zero)

Construct a rounded rectangle from its left, top, right, and bottom edges, and topLeft, topRight, bottomRight, and bottomLeft radii.

RRect
RRect(rect: Rect, topLeft: Radius = Radius.zero, topRight: Radius = Radius.zero, bottomRight: Radius = Radius.zero, bottomLeft: Radius = Radius.zero)

Construct a rounded rectangle from its bounding box and and topLeft, topRight, bottomRight, and bottomLeft radii.

RRect
lerp(start: RRect, stop: RRect, fraction: Float)

Linearly interpolate between two rounded rectangles.

Radius
lerp(start: Radius, stop: Radius, fraction: Float)

Linearly interpolate between two radii.

Rect
lerp(start: Rect, stop: Rect, fraction: Float)

Linearly interpolate between two rectangles.

Extension functions summary

For Path
Unit

Adds the outline to the Path.

For RRect
Radius

The bottom-left Radius.

Radius

The bottom-right Radius.

Offset

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

RRect
RRect.grow(delta: Float)

Returns a new RRect with edges and radii moved outwards by the given delta.

Rect

The rectangle that would be formed using the axis-aligned intersection of the sides of the rectangle, i.

Rect

The bounding box of this rounded rectangle (the rectangle with no rounded corners).

Rect

The non-rounded rectangle that is constrained by the smaller of the two diagonals, with each diagonal traveling through the middle of the curve corners.

RRect
RRect.shift(offset: Offset)

Returns a new RRect translated by the given offset.

RRect
RRect.shrink(delta: Float)

Returns a new RRect with edges and radii moved inwards by the given delta.

Rect

The biggest rectangle that is entirely inside the rounded rectangle and has the full height of the rounded rectangle.

Radius

The top-left Radius.

Radius

The top-right Radius.

Rect

The biggest rectangle that is entirely inside the rounded rectangle and has the full width of the rounded rectangle.

RRect

For Canvas
Unit
Canvas.drawOutline(outline: Outline, paint: Paint)

Draws the Outline on a Canvas.

For Offset
PxPosition

Extension properties summary

For RRect
Boolean

Whether this rounded rectangle would draw as a circle.

Boolean

Whether this rounded rectangle has no side with a straight section.

Boolean

Whether this rounded rectangle encloses a non-zero area.

Boolean

Whether all coordinates of this rounded rectangle are finite.

Boolean

Whether this rounded rectangle is a simple rectangle with zero corner radii.

Boolean

Whether this rounded rectangle has a side with no straight section.

Float

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

Float

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

Top-level functions

RRect

fun RRect(
    left: Float,
    top: Float,
    right: Float,
    bottom: Float,
    radiusX: Float,
    radiusY: Float
): RRect

Construct a rounded rectangle from its left, top, right, and bottom edges, and the same radii along its horizontal axis and its vertical axis.

RRect

fun RRect(
    left: Float,
    top: Float,
    right: Float,
    bottom: Float,
    radius: Radius
): RRect

Construct a rounded rectangle from its left, top, right, and bottom edges, and the same radius in each corner.

RRect

fun RRect(
    rect: Rect,
    radiusX: Float,
    radiusY: Float
): RRect

Construct a rounded rectangle from its bounding box and the same radii along its horizontal axis and its vertical axis.

RRect

fun RRect(
    rect: Rect,
    radius: Radius
): RRect

Construct a rounded rectangle from its bounding box and a radius that is the same in each corner.

RRect

fun RRect(
    left: Float,
    top: Float,
    right: Float,
    bottom: Float,
    topLeft: Radius = Radius.zero,
    topRight: Radius = Radius.zero,
    bottomRight: Radius = Radius.zero,
    bottomLeft: Radius = Radius.zero
): RRect

Construct a rounded rectangle from its left, top, right, and bottom edges, and topLeft, topRight, bottomRight, and bottomLeft radii.

The corner radii default to Radius.zero, i.e. right-angled corners.

RRect

fun RRect(
    rect: Rect,
    topLeft: Radius = Radius.zero,
    topRight: Radius = Radius.zero,
    bottomRight: Radius = Radius.zero,
    bottomLeft: Radius = Radius.zero
): RRect

Construct a rounded rectangle from its bounding box and and topLeft, topRight, bottomRight, and bottomLeft radii.

The corner radii default to Radius.zero, i.e. right-angled corners

lerp

fun lerp(
    start: RRect,
    stop: RRect,
    fraction: Float
): RRect

Linearly interpolate between two rounded rectangles.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves).

Values for fraction are usually obtained from an Animation, such as an AnimationController.

lerp

fun lerp(
    start: Radius,
    stop: Radius,
    fraction: Float
): Radius

Linearly interpolate between two radii.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves).

Values for fraction are usually obtained from an Animation, such as an AnimationController.

lerp

fun lerp(
    start: Rect,
    stop: Rect,
    fraction: Float
): Rect

Linearly interpolate between two rectangles.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves).

Values for fraction are usually obtained from an Animation, such as an AnimationController.

Extension functions

addOutline

fun Path.addOutline(outline: Outline
): Unit

Adds the outline to the Path.

bottomLeftRadius

fun RRect.bottomLeftRadius(): Radius

The bottom-left Radius.

bottomRightRadius

fun RRect.bottomRightRadius(): Radius

The bottom-right Radius.

center

fun RRect.center(): Offset

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

drawOutline

fun Canvas.drawOutline(
    outline: Outline,
    paint: Paint
): Unit

Draws the Outline on a Canvas.

Parameters
outline: Outline = null: Outline the outline to draw.
paint: Paint = null: Paint the paint used for the drawing.

grow

fun RRect.grow(delta: Float
): RRect

Returns a new RRect with edges and radii moved outwards by the given delta.

middleRect

fun RRect.middleRect(): Rect

The rectangle that would be formed using the axis-aligned intersection of the sides of the rectangle, i.e., the rectangle formed from the inner-most centers of the ellipses that form the corners. This is the intersection of the wideMiddleRect and the tallMiddleRect. If any of the intersections are void, the resulting Rect will have negative width or height.

outerRect

fun RRect.outerRect(): Rect

The bounding box of this rounded rectangle (the rectangle with no rounded corners).

safeInnerRect

fun RRect.safeInnerRect(): Rect

The non-rounded rectangle that is constrained by the smaller of the two diagonals, with each diagonal traveling through the middle of the curve corners. The middle of a corner is the intersection of the curve with its respective quadrant bisector.

shift

fun RRect.shift(offset: Offset
): RRect

Returns a new RRect translated by the given offset.

shrink

fun RRect.shrink(delta: Float
): RRect

Returns a new RRect with edges and radii moved inwards by the given delta.

tallMiddleRect

fun RRect.tallMiddleRect(): Rect

The biggest rectangle that is entirely inside the rounded rectangle and has the full height of the rounded rectangle. If the rounded rectangle does not have an axis-aligned intersection of its top and bottom side, the resulting Rect will have negative width or height.

toPxPosition

fun Offset.toPxPosition(): PxPosition

topLeftRadius

fun RRect.topLeftRadius(): Radius

The top-left Radius.

topRightRadius

fun RRect.topRightRadius(): Radius

The top-right Radius.

wideMiddleRect

fun RRect.wideMiddleRect(): Rect

The biggest rectangle that is entirely inside the rounded rectangle and has the full width of the rounded rectangle. If the rounded rectangle does not have an axis-aligned intersection of its left and right side, the resulting Rect will have negative width or height.

withRadius

fun RRect.withRadius(radius: Radius
): RRect

Extension properties

isCircle

val RRect.isCircle: Boolean

Whether this rounded rectangle would draw as a circle.

isEllipse

val RRect.isEllipse: Boolean

Whether this rounded rectangle has no side with a straight section.

isEmpty

val RRect.isEmpty: Boolean

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

isFinite

val RRect.isFinite: Boolean

Whether all coordinates of this rounded rectangle are finite.

isRect

val RRect.isRect: Boolean

Whether this rounded rectangle is a simple rectangle with zero corner radii.

isStadium

val RRect.isStadium: Boolean

Whether this rounded rectangle has a side with no straight section.

longestSide

val RRect.longestSide: Float

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

shortestSide

val RRect.shortestSide: Float

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