value class Meter : Comparable


Represents a dimension value in meters within 3D space.

This is the standard unit used by the system for representing size and distance in 3D environments.

Summary

Public companion functions

inline Meter
fromPixel(px: Float, density: Density)

Creates a Meter value from a given number of pixels.

Public companion properties

Meter

Represents an infinite distance in meters.

Meter

Represents an undefined or unrepresentable distance in meters.

Meter

Creates a Meter from the Double centimeter value.

Meter

Creates a Meter from the Float centimeter value.

Meter

Creates a Meter from the Int centimeter value.

Meter

Creates a Meter from the Double meter value.

Meter

Creates a Meter from the Float meter value.

Meter

Creates a Meter from the Int meter value.

Meter

Creates a Meter from the Double millimeter value.

Meter

Creates a Meter from the Float millimeter value.

Meter

Creates a Meter from the Int millimeter value.

Public constructors

Meter(value: Float)

Public functions

open operator Int
compareTo(other: Meter)

Compares this Meter value to other.

inline operator Meter
div(other: Double)

Divides this Meter value by a Double factor.

inline operator Meter
div(other: Float)

Divides this Meter value by a Float factor.

inline operator Meter
div(other: Int)

Divides this Meter value by an Int factor.

inline operator Meter
minus(other: Meter)

Subtracts another Meter value from this one.

inline operator Meter
plus(other: Meter)

Adds another Meter value to this one.

inline Int
roundToPx(density: Density)

Converts this Meter value to the nearest Int number of pixels, taking into account density.

inline operator Meter
times(other: Double)

Multiplies this Meter value by a Double factor.

inline operator Meter
times(other: Float)

Multiplies this Meter value by a Float factor.

inline operator Meter
times(other: Int)

Multiplies this Meter value by an Int factor.

inline Float

Converts this Meter value to Float centimeters.

inline Dp

Converts this Meter value to the Dp number of density-independent pixels it contains.

inline Float
toM()

Converts this Meter value to Float meters.

inline Float

Converts this Meter value to Float millimeters.

inline Float
toPx(density: Density)

Converts this Meter value to an approximate number of pixels it contains.

Public properties

Boolean

Checks if this Meter value is finite.

Boolean

Checks if this Meter value is specified (i.e., not NaN).

Float

Public companion functions

fromPixel

Added in 1.0.0-alpha01
inline fun fromPixel(px: Float, density: Density): Meter

Creates a Meter value from a given number of pixels.

Parameters
px: Float

the number of pixels.

density: Density

The pixel density of the display.

Returns
Meter

a Meter value representing the equivalent distance in meters.

Public companion properties

Infinity

Added in 1.0.0-alpha01
val InfinityMeter

Represents an infinite distance in meters.

NaN

Added in 1.0.0-alpha01
val NaNMeter

Represents an undefined or unrepresentable distance in meters.

val Double.centimetersMeter

Creates a Meter from the Double centimeter value.

val Float.centimetersMeter

Creates a Meter from the Float centimeter value.

val Int.centimetersMeter

Creates a Meter from the Int centimeter value.

val Double.metersMeter

Creates a Meter from the Double meter value.

val Float.metersMeter

Creates a Meter from the Float meter value.

val Int.metersMeter

Creates a Meter from the Int meter value.

val Double.millimetersMeter

Creates a Meter from the Double millimeter value.

val Float.millimetersMeter

Creates a Meter from the Float millimeter value.

val Int.millimetersMeter

Creates a Meter from the Int millimeter value.

Public constructors

Meter

Added in 1.0.0-alpha01
Meter(value: Float)

Public functions

compareTo

open operator fun compareTo(other: Meter): Int

Compares this Meter value to other.

Parameters
other: Meter

The other Meter value to compare to.

Returns
Int

a negative value if this Meter is less than other, a positive value if it's greater, or 0 if they are equal.

div

Added in 1.0.0-alpha01
inline operator fun div(other: Double): Meter

Divides this Meter value by a Double factor.

Parameters
other: Double

the Double factor to divide by.

Returns
Meter

a new Meter representing the quotient.

div

Added in 1.0.0-alpha01
inline operator fun div(other: Float): Meter

Divides this Meter value by a Float factor.

Parameters
other: Float

the Float factor to divide by.

Returns
Meter

a new Meter representing the quotient.

div

Added in 1.0.0-alpha01
inline operator fun div(other: Int): Meter

Divides this Meter value by an Int factor.

Parameters
other: Int

the Int factor to divide by.

Returns
Meter

a new Meter representing the quotient.

minus

inline operator fun minus(other: Meter): Meter

Subtracts another Meter value from this one.

Parameters
other: Meter

the Meter value to subtract.

Returns
Meter

a new Meter representing the difference between the two values.

plus

inline operator fun plus(other: Meter): Meter

Adds another Meter value to this one.

Parameters
other: Meter

the Meter value to add.

Returns
Meter

a new Meter representing the sum of the two values.

roundToPx

Added in 1.0.0-alpha01
inline fun roundToPx(density: Density): Int

Converts this Meter value to the nearest Int number of pixels, taking into account density.

Returns
Int

the rounded equivalent value in pixels as an Int.

times

Added in 1.0.0-alpha01
inline operator fun times(other: Double): Meter

Multiplies this Meter value by a Double factor.

Parameters
other: Double

the double factor to multiply by.

Returns
Meter

a new Meter representing the product.

times

Added in 1.0.0-alpha01
inline operator fun times(other: Float): Meter

Multiplies this Meter value by a Float factor.

Parameters
other: Float

the float factor to multiply by.

Returns
Meter

a new Meter representing the product.

times

Added in 1.0.0-alpha01
inline operator fun times(other: Int): Meter

Multiplies this Meter value by an Int factor.

Parameters
other: Int

the integer factor to multiply by.

Returns
Meter

a new Meter representing the product.

toCm

Added in 1.0.0-alpha01
inline fun toCm(): Float

Converts this Meter value to Float centimeters.

Returns
Float

the equivalent value in centimeters as a Float.

toDp

Added in 1.0.0-alpha01
inline fun toDp(): Dp

Converts this Meter value to the Dp number of density-independent pixels it contains.

Returns
Dp

the equivalent value in Dp.

toM

Added in 1.0.0-alpha01
inline fun toM(): Float

Converts this Meter value to Float meters.

Returns
Float

the equivalent value in meters as a Float.

toMm

Added in 1.0.0-alpha01
inline fun toMm(): Float

Converts this Meter value to Float millimeters.

Returns
Float

the equivalent value in millimeters as a Float.

toPx

Added in 1.0.0-alpha01
inline fun toPx(density: Density): Float

Converts this Meter value to an approximate number of pixels it contains.

Returns
Float

the approximate equivalent value in pixels as a Float.

Public properties

isFinite

val isFiniteBoolean

Checks if this Meter value is finite.

Returns
Boolean

true if the value is finite, false when Meter.Infinity.

isSpecified

val isSpecifiedBoolean

Checks if this Meter value is specified (i.e., not NaN).

Returns
Boolean

true if the value is specified, false otherwise.

value

Added in 1.0.0-alpha01
val valueFloat