class PixelDensity


Represents a pixel density, analogous to the pixel density of a physical display like a computer monitor or TV. It defines the mapping between pixels and physical distance in meters.

Use this class to perform consistent unit conversions between the pixel-based coordinate systems and physical spatial dimensions.

Summary

Public functions

Float

Converts a physical distance in meters to a pixel count using this density.

Float

Converts a pixel count to a physical distance in meters using this density.

Public properties

Float

The number of pixels that correspond to one physical meter.

Public functions

convertMetersToPixels

Added in 1.0.0-alpha16
fun convertMetersToPixels(meters: Float): Float

Converts a physical distance in meters to a pixel count using this density.

convertPixelsToMeters

Added in 1.0.0-alpha16
fun convertPixelsToMeters(pixels: Float): Float

Converts a pixel count to a physical distance in meters using this density.

Public properties

pixelsPerMeter

Added in 1.0.0-alpha16
val pixelsPerMeterFloat

The number of pixels that correspond to one physical meter. Must be a positive and finite value.