TimelineZoom

A zoom level, as one step on a ladder that doubles.

Each step doubles pixelsPerSecond. A StripGrid samples its tiles at their leading edges, so every position at one step is still a position at the next one in, and a strip that zooms keeps the frames it has already decoded and asks only for the ones that fall between them.

of reads the ladder at its own numbers. fitting scales the whole ladder so its step lands exactly on the viewport, and zoomedIn and zoomedOut stay on that scaled ladder. A fit and of at the same step are only equal when the fit landed on a step of the unscaled ladder.

A timeline handed a zoom stops pinching, since the host now owns the ladder. Stepping it from outside holds no focal point still either, which is what TimelineState.zoomTo is for.

var zoom by remember(duration) { mutableStateOf(TimelineZoom.fitting(duration, viewportWidthPx)) }

Column {
FilmstripTimeline(
// ...
zoom = zoom,
)

Row {
Button(
onClick = { zoom = zoom.zoomedOut() },
enabled = zoom.step > TimelineZoom.Steps.first,
) { Text("Zoom out") }

Button(
onClick = { zoom = zoom.zoomedIn() },
enabled = zoom.step < TimelineZoom.Steps.last,
) { Text("Zoom in") }
}
}

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

How wide one second is drawn at this step.

Link copied to clipboard
val step: Int

Where on the ladder this sits, in Steps .

Functions

Link copied to clipboard

The scale this step draws duration at.

Link copied to clipboard

The next step in, or this one at the top of the ladder.

Link copied to clipboard

The next step out, or this one at the bottom of the ladder.