Package-level declarations

The two entry points with their fetch companion scanSvgRefs, the JVM File conveniences, and the sealed SvgFormatException hierarchy naming every way a document or scene can fail the format.

The element vocabulary

Seven SVG elements carry the eight CGA shapes and the group tree. Element identity is resolved by k:type, never by geometry.

ElementReading
<rect>a rectangle Polygon (parse-only — a save writes <polygon>); a FlatPoint when k:type="flat-point"
<circle>a Circle; a RoundPoint when k:type="round-point"
<line>a Segment; an infinite Line when k:type="line"
<polygon>a Polygon
<polyline>a Polyline
<g>a nested GroupNode; a Dipole when k:type="dipole"
<use href="doc.svg">parse-only expansion of an external template document — a save writes the placed shapes

Degenerate CGA states persist faithfully: imaginary and inside-out circles ride k:flags, an imaginary dipole needs no flag at all (its round-point children rebuild it exactly), and an infinite line writes display endpoints on the scene's world border. Only a shape the format cannot place — a line or dipole endpoint at infinity — is skipped with a warning on save.

The two entry points with their fetch companion scanSvgRefs, the JVM File conveniences, and the sealed SvgFormatException hierarchy naming every way a document or scene can fail the format.

The element vocabulary

Seven SVG elements carry the eight CGA shapes and the group tree. Element identity is resolved by k:type, never by geometry.

ElementReading
<rect>a rectangle Polygon (parse-only — a save writes <polygon>); a FlatPoint when k:type="flat-point"
<circle>a Circle; a RoundPoint when k:type="round-point"
<line>a Segment; an infinite Line when k:type="line"
<polygon>a Polygon
<polyline>a Polyline
<g>a nested GroupNode; a Dipole when k:type="dipole"
<use href="doc.svg">parse-only expansion of an external template document — a save writes the placed shapes

Degenerate CGA states persist faithfully: imaginary and inside-out circles ride k:flags, an imaginary dipole needs no flag at all (its round-point children rebuild it exactly), and an infinite line writes display endpoints on the scene's world border. Only a shape the format cannot place — a line or dipole endpoint at infinity — is skipped with a warning on save.

Types

Link copied to clipboard
class MalformedCircleException(reason: String, location: String? = null) : SvgFormatException

The rejection of a <circle> with no usable radius.

Link copied to clipboard
class MalformedDipoleException(reason: String, location: String? = null) : SvgFormatException

The rejection of a dipole carrier <g k:type="dipole"> that holds no valid endpoint pair.

Link copied to clipboard
class MalformedLineException(reason: String, location: String? = null) : SvgFormatException

The rejection of a <line k:type="line"> missing part of its geometry.

Link copied to clipboard
class MalformedPolygonException(reason: String, location: String? = null) : SvgFormatException

The rejection of a <polygon> whose points close no polygon.

Link copied to clipboard
class MalformedPolylineException(reason: String, location: String? = null) : SvgFormatException

The rejection of a <polyline> whose points chain into no polyline.

Link copied to clipboard
class MalformedRectException(reason: String, location: String? = null) : SvgFormatException

The rejection of a <rect> that fits neither of the element's two readings.

Link copied to clipboard
class MalformedRoundPointException(reason: String, location: String? = null) : SvgFormatException

The rejection of a round-point <circle> (k:type="round-point") with no usable marker size.

Link copied to clipboard
class MalformedSegmentException(reason: String, location: String? = null) : SvgFormatException

The rejection of a bare <line> that builds no segment.

Link copied to clipboard
class MalformedTemplateException(reason: String, location: String? = null) : SvgFormatException

The rejection of a template document that violates the template size contract.

Link copied to clipboard
class MalformedUseException(reason: String, location: String? = null) : SvgFormatException

The rejection of a <use> that doesn't fit the format's external-template form.

Link copied to clipboard

The rejection of a viewBox attribute that describes no viewport.

Link copied to clipboard

The rejection of input with no <svg> element at all — nothing to parse.

Link copied to clipboard
class MissingTemplateException(val href: String, location: String? = null) : SvgFormatException

The absence of a template document a <use> references.

Link copied to clipboard

The absence of a viewport on the document or scene root.

Link copied to clipboard

The violation of the /v1 format by a document or scene — the sealed base of every failure the module's entry points raise.

Link copied to clipboard

The rejection of template documents that reference each other in a loop.

Link copied to clipboard
class UnsupportedPaintException(val value: String, location: String? = null) : SvgFormatException

The rejection of a paint value outside the /v1 color grammar.

Link copied to clipboard
class UnsupportedSvgElementException(val elementName: String, location: String? = null) : SvgFormatException

The rejection of an SVG element outside the /v1 vocabulary.

Functions

Link copied to clipboard
fun parseSvg(content: String, templates: Map<String, String> = emptyMap()): GroupNode

Parses content, an SVG document in the module's /v1 format, into a GroupNode scene.

Link copied to clipboard

Parses this file's UTF-8 SVG text into a GroupNode scene.

Link copied to clipboard
fun scanSvgRefs(content: String): Set<String>

Returns the paths of the external documents content references through <use>.

Link copied to clipboard

Serializes root into SVG text in the module's /v1 format.

Link copied to clipboard

Writes this scene to file as UTF-8 SVG text in the module's /v1 format.