Skip to content

v1.10.0 β€” Shape-morph clips (OGMorphShape) 🫧

Choose a tag to compare

@ozgesolidkey ozgesolidkey released this 27 Sep 12:10
· 6 commits to main since this release

Morph the clip mask itself

New this release: OGMorphShape β€” a Compose Shape whose outline morphs from one shape to another as you drive progress 0f β†’ 1f. Because every KMPMedia media surface clips through a plain Shape (OGImageView.clipShape, OGPlayerConfig.clipShape, any Modifier.clip), it drops straight into that existing slot β€” so a live video, GIF or photo can be masked by an outline that animates circle β†’ diamond β†’ triangle β†’ lasso while the media keeps playing, with no new surface API.

  • OGMorphShape(from, to, progress) β€” morph a mask between any two shapes (built-ins, a RoundedCornerShape, or an OGPolygonShape lasso).
  • ogMorphSequence(stops, progress) β€” one progress walks a whole chain of shapes for a seamless multi-stop loop.
  • Drive progress from any Compose animation (animateFloatAsState, an infinite transition, a slider).

Built for 60fps (the perf + simplicity gate)

Each endpoint outline is resampled once into equally-spaced perimeter points and cached by (from, to, size); per frame only those two point lists are lerped β€” no re-measure, no allocation churn. At progress ≀ 0 / β‰₯ 1 the raw endpoint outline passes straight through, so a settled clip costs nothing. Mismatched winding is auto-aligned so shapes morph without swirling. Same sample-once / lerp-per-frame approach as the SVG path morph.

Install

implementation("se.solidkey:kmpmedia-lib:1.10.0")

Identical on Android & iOS. See docs/SHAPE_MORPH_CLIPS.md. Tests green on JVM host + iOS; dogfooded in the demo's "Morph the clip itself" screen and the UFO Dodge shape-shifting hazard.