load

inline suspend fun <N : ShapeNode> load(path: String): N

Loads the single-shape SVG document at path as its typed leaf — load<PolygonNode>("files/sprite.svg") yields a PolygonNode.

What a document contains is unknowable at compile time, so the one unavoidable runtime assertion lives here, at the load boundary, with an error naming the found and expected types — everything downstream works on the typed leaf cast-free, style and tags riding along. The document loads exactly like loadGroup, <use> templates included.

Return

The document's one leaf as N.

Parameters

path

The document's resource path.

Type Parameters

N

The expected concrete ShapeNode type.

Throws

when the document holds no shape at all.

when the document holds more than one shape, or its leaf is not an N.

when a document violates the /v1 format — every failure is a subtype naming its condition.