Class

Meter

Represents a dimension value in meters within 3D space.

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free
Android
public value class Meter(public val value: Float) : Comparable<Meter>

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.

Functions

plus

public inline operator fun plus(other: Meter): Meter

Adds another Meter value to this one.

Parameters

other the Meter value to add.

Returns

a new Meter representing the sum of the two values.

minus

public inline operator fun minus(other: Meter): Meter

Subtracts another Meter value from this one.

Parameters

other the Meter value to subtract.

Returns

a new Meter representing the difference between the two values.

times

public inline operator fun times(other: Int): Meter

Multiplies this Meter value by an Int factor.

Parameters

other the integer factor to multiply by.

Returns

a new Meter representing the product.

times

public inline operator fun times(other: Float): Meter

Multiplies this Meter value by a Float factor.

Parameters

other the float factor to multiply by.

Returns

a new Meter representing the product.

times

public inline operator fun times(other: Double): Meter

Multiplies this Meter value by a Double factor.

Parameters

other the double factor to multiply by.

Returns

a new Meter representing the product.

div

public inline operator fun div(other: Int): Meter

Divides this Meter value by an Int factor.

Parameters

other the Int factor to divide by.

Returns

a new Meter representing the quotient.

div

public inline operator fun div(other: Float): Meter

Divides this Meter value by a Float factor.

Parameters

other the Float factor to divide by.

Returns

a new Meter representing the quotient.

div

public inline operator fun div(other: Double): Meter

Divides this Meter value by a Double factor.

Parameters

other the Double factor to divide by.

Returns

a new Meter representing the quotient.

toMm

public inline fun toMm(): Float

Converts this Meter value to Float millimeters.

Returns

the equivalent value in millimeters as a Float.

toCm

public inline fun toCm(): Float

Converts this Meter value to Float centimeters.

Returns

the equivalent value in centimeters as a Float.

toM

public inline fun toM(): Float

Converts this Meter value to Float meters.

Returns

the equivalent value in meters as a Float.

toPx

public inline fun toPx(density: Density): Float

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

Returns

the approximate equivalent value in pixels as a Float.

roundToPx

public inline fun roundToPx(density: Density): Int

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

Returns

the rounded equivalent value in pixels as an Int.

toDp

public inline fun toDp(): Dp

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

Returns

the equivalent value in Dp.

Companion Object

Properties

Android
public val Infinity: Meter

Represents an infinite distance in meters.

Android
public val NaN: Meter

Represents an undefined or unrepresentable distance in meters.

Android
public val Int.millimeters: Meter

Creates a Meter from the Int millimeter value.

Android
public val Float.millimeters: Meter

Creates a Meter from the Float millimeter value.

Android
public val Double.millimeters: Meter

Creates a Meter from the Double millimeter value.

Android
public val Int.centimeters: Meter

Creates a Meter from the Int centimeter value.

Android
public val Float.centimeters: Meter

Creates a Meter from the Float centimeter value.

Android
public val Double.centimeters: Meter

Creates a Meter from the Double centimeter value.

Android
public val Int.meters: Meter

Creates a Meter from the Int meter value.

Android
public val Float.meters: Meter

Creates a Meter from the Float meter value.

Android
public val Double.meters: Meter

Creates a Meter from the Double meter value.

Methods


fromPixel

Android
public inline fun fromPixel(px: Float, density: Density): Meter

Creates a Meter value from a given number of pixels.

Parameters

px the number of pixels.
density The pixel density of the display.

Returns

a Meter value representing the equivalent distance in meters.