Skip to content

v1.7.0 β€” Runtime-editable SVG 🎨

Choose a tag to compare

@ozgesolidkey ozgesolidkey released this 23 Sep 14:31
· 16 commits to main since this release

🎨 Runtime-editable SVG

KMPMedia parses an SVG into a live node tree β€” so from 1.7.0 you can address any node by its id and change its attributes at runtime, bound to Compose state. A static .svg becomes a live template: gauges, charts, progress rings, status icons. The source is parsed once; only the overrides change and it redraws live. Same code on Android and iOS.

OGSVGView(
    source = OGSvgUrlType("gauge.svg"),
    width = 300f, height = 195f,
    overrides = mapOf(
        "needle" to OGSvgNodeOverride(rotation = angle, rotationCx = 100f, rotationCy = 105f),
        "arc"    to OGSvgNodeOverride(stroke = zoneColor),
        "status" to OGSvgNodeOverride(fill = zoneColor),
    ),
)
  • OGSvgNodeOverride β€” a per-node override; every field nullable (null = keep original): fill, stroke, strokeWidth, translateX/translateY, rotation (+ rotationCx/rotationCy pivot), scaleX/scaleY.
  • Change the overrides map from state β†’ only the matched nodes re-resolve, no re-parse of the source.
  • Paint folds into the node's style; transforms apply uniformly at draw time, so they work on any shape type.
  • Purely additive β€” overrides defaults to empty, so every existing OGSVGView call is unchanged.

Install

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

Cumulative superset β€” also includes animated GIF playback, video/image playback & seek, depth-layer, polygon lasso, video clip-to-shape and audio sprites from prior releases.

πŸ“– Docs: docs/RUNTIME_SVG.md Β· πŸ—ΊοΈ ROADMAP Β· πŸ“ CHANGELOG

πŸŽ₯ See the live gauge (needle + zones driven by a slider, Android + iOS) in the demo app's Runtime-editable SVG screen.