fitScale

fun fitScale(size: Size, bounds: SceneBounds?, density: Float): Float

Returns the draw scale — physical px per CGA unit — fitting a scene with bounds onto a surface of size: the one value the draw pass and pointer-input conversion must share.

The scale is uniform: the bounds rectangle fits the surface whole, aspect preserved, so a mismatched surface letterboxes rather than stretches. Null bounds falls back to the display density, one CGA unit per dp on screen.

Return

The uniform draw scale in physical px per CGA unit.

Parameters

size

The surface size in physical px.

bounds

The scene's SceneBounds, or null when the scene declares none.

density

The display density (physical px per dp) — the null-bounds fallback scale.