🌈 Create new beautiful Compose Gradients with our new wesite ->
Interface

Density

A density of the screen.

Source set: Common
public interface Density : FontScaling

A density of the screen. Used for the conversions between pixels, Dp, Int and TextUnit.

Properties

density

Source set: Common
@Stable public val density: Float

The logical density of the display. This is a scaling factor for the Dp unit.

Functions

toPx

Source set: Common
@Stable public fun Dp.toPx(): Float

Convert Dp to pixels. Pixels are used to paint to Canvas.

roundToPx

Source set: Common
public fun Dp.roundToPx(): Int

Convert Dp to Int by rounding

toPx

Source set: Common
public fun TextUnit.toPx(): Float

Convert Sp to pixels. Pixels are used to paint to Canvas.

Throws: IllegalStateException

if TextUnit other than SP unit is specified.

roundToPx

Source set: Common
@Stable public fun TextUnit.roundToPx(): Int

Convert Sp to Int by rounding

toDp

Source set: Common
@Stable public fun Int.toDp(): Dp

Convert an Int pixel value to Dp.

toSp

Source set: Common
@Stable public fun Int.toSp(): TextUnit

Convert an Int pixel value to Sp.

toDp

Source set: Common
@Stable public fun Float.toDp(): Dp

Convert a Float pixel value to a Dp

toSp

Source set: Common
@Stable public fun Float.toSp(): TextUnit

Convert a Float pixel value to a Sp

toRect

Source set: Common
public fun DpRect.toRect(): Rect

Convert a DpRect to a Rect.

toSize

Source set: Common
public fun DpSize.toSize(): Size

Convert a DpSize to a Size.

toDpSize

Source set: Common
public fun Size.toDpSize(): DpSize

Convert a Size to a DpSize.