fitting

fun fitting(duration: Duration, viewportWidthPx: Float): TimelineZoom(source)

The zoom whose content fills viewportWidthPx without going past it.

The step is the widest one that still fits, and the ladder is scaled so that step draws duration across the whole viewport. A duration too short for the top step scales the ladder further and still fills. The content is fitted to the viewport's whole pixels, since tiles are laid out in them and a viewport measured through Dp can land a rounding error past its pixel.

Return

The fit, and the bottom of the unscaled ladder for a timeline too long to fit at any step or when there is no duration or finite width to fit.

Parameters

duration

How much source time the timeline covers.

viewportWidthPx

How wide the timeline is drawn.