androidx.xr.compose.unit

Classes

DpVolumeSize

Represents the size of a volume in density-independent pixels (Dp).

IntVolumeSize

Represents the size of a volume in pixels.

Meter

Represents a dimension value in meters within 3D space.

VolumeConstraints

Defines constraints for a 3D volume, specifying minimum and maximum values for width, height, and depth.

Extension functions summary

VolumeConstraints

Constrains the dimensions of this VolumeConstraints object to fit within the bounds of the other VolumeConstraints object.

Int

Constrains a given depth value to fit within the bounds of this VolumeConstraints object.

Int

Constrains a given height value to fit within the bounds of this VolumeConstraints object.

Int

Constrains a given width value to fit within the bounds of this VolumeConstraints object.

inline operator Meter
Int.div(other: Meter)
inline operator Meter
Float.div(other: Meter)
inline operator Meter
Double.div(other: Meter)
VolumeConstraints
VolumeConstraints.offset(
    horizontal: Int,
    vertical: Int,
    depth: Int,
    resetMins: Boolean
)

Creates a new VolumeConstraints object by offsetting the minimum and maximum values of this one.

inline operator Meter
Int.times(other: Meter)
inline operator Meter
Float.times(other: Meter)
inline operator Meter
Double.times(other: Meter)
inline Meter

Converts a Dp value to Meter.

Extension functions

fun VolumeConstraints.constrain(otherConstraints: VolumeConstraints): VolumeConstraints

Constrains the dimensions of this VolumeConstraints object to fit within the bounds of the other VolumeConstraints object.

Parameters
otherConstraints: VolumeConstraints

the other VolumeConstraints to constrain against.

Returns
VolumeConstraints

a new VolumeConstraints object with dimensions constrained within the bounds of otherConstraints.

constrainDepth

fun VolumeConstraints.constrainDepth(depth: Int): Int

Constrains a given depth value to fit within the bounds of this VolumeConstraints object.

Parameters
depth: Int

the depth value to constrain.

Returns
Int

the constrained depth value, ensuring it's within the minimum and maximum depth bounds.

constrainHeight

fun VolumeConstraints.constrainHeight(height: Int): Int

Constrains a given height value to fit within the bounds of this VolumeConstraints object.

Parameters
height: Int

the height value to constrain.

Returns
Int

the constrained height value, ensuring it's within the minimum and maximum height bounds.

constrainWidth

fun VolumeConstraints.constrainWidth(width: Int): Int

Constrains a given width value to fit within the bounds of this VolumeConstraints object.

Parameters
width: Int

the width value to constrain.

Returns
Int

the constrained width value, ensuring it's within the minimum and maximum width bounds.

inline operator fun Int.div(other: Meter): Meter
inline operator fun Float.div(other: Meter): Meter
inline operator fun Double.div(other: Meter): Meter
fun VolumeConstraints.offset(
    horizontal: Int = 0,
    vertical: Int = 0,
    depth: Int = 0,
    resetMins: Boolean = false
): VolumeConstraints

Creates a new VolumeConstraints object by offsetting the minimum and maximum values of this one.

Parameters
horizontal: Int = 0

the horizontal offset to apply.

vertical: Int = 0

the vertical offset to apply.

depth: Int = 0

the depth offset to apply.

resetMins: Boolean = false

if true, the minimum values in the new constraints will be set to 0, otherwise. they will be offset.

Returns
VolumeConstraints

a new VolumeConstraints object with offset values.

inline operator fun Int.times(other: Meter): Meter
inline operator fun Float.times(other: Meter): Meter
inline operator fun Double.times(other: Meter): Meter
inline fun Dp.toMeter(): Meter

Converts a Dp value to Meter.

Handles unspecified and infinite Dp values gracefully.

Returns
Meter

the equivalent value in meters, or Meter.NaN if the Dp is unspecified, or Meter.Infinity if the Dp is infinite.