v1.7.0 β Runtime-editable SVG π¨
π¨ 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/rotationCypivot),scaleX/scaleY.- Change the
overridesmap 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 β
overridesdefaults to empty, so every existingOGSVGViewcall 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.