Move KSVG to JS externals subproject
authorLanius Trolling <lanius@laniustrolling.dev>
Thu, 7 Mar 2024 12:48:39 +0000 (07:48 -0500)
committerLanius Trolling <lanius@laniustrolling.dev>
Thu, 7 Mar 2024 12:48:39 +0000 (07:48 -0500)
70 files changed:
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/HtmlUtils.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/RenderMode.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/AttributeProperty.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/AttributeType.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasAttributes.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasAttributesImpl.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasClipPath.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasClipPathImpl.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasDimensions.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasDimensionsImpl.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasFill.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasFillImpl.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasOrigin.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasOriginImpl.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasStroke.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasStrokeImpl.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/A.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/CIRCLE.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/CLIPPATH.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/Container.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/DEFS.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/Element.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/G.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/IMAGE.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/LINE.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/PATH.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/POLYGON.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/RECT.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/Region.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/STYLE.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/SVG.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/SvgTagMarker.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/TEXT.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/TITLE.kt [new file with mode: 0644]
externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/USE.kt [new file with mode: 0644]
src/mapMain/kotlin/com/github/nwillc/ksvg/HtmlUtils.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/RenderMode.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/AttributeProperty.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/AttributeType.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasAttributes.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasAttributesImpl.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasClipPath.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasClipPathImpl.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasDimensions.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasDimensionsImpl.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasFill.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasFillImpl.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasOrigin.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasOriginImpl.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasStroke.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasStrokeImpl.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/A.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/CIRCLE.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/CLIPPATH.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/Container.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/DEFS.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/Element.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/G.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/IMAGE.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/LINE.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/PATH.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/POLYGON.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/RECT.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/Region.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/STYLE.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/SVG.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/SvgTagMarker.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/TEXT.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/TITLE.kt [deleted file]
src/mapMain/kotlin/com/github/nwillc/ksvg/elements/USE.kt [deleted file]

diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/HtmlUtils.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/HtmlUtils.kt
new file mode 100644 (file)
index 0000000..4ce81f4
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg
+
+internal const val EIGHT_BIT_START = 127.toChar()
+
+/**
+ * Escapes special characters of an Appendable for HTML output. Handles double quotes,
+ * greater than, less than, ampersand, and characters greater than eight bit.
+ * @param csq A sequence of characters to HTML escape.
+ */
+fun Appendable.escapeHTML(csq: CharSequence) {
+       for (c in csq) {
+               when {
+                       c > EIGHT_BIT_START || c == '"' || c == '<' || c == '>' || c == '&' -> {
+                               append("&#")
+                               append(c.code.toString())
+                               append(';')
+                       }
+                       
+                       else -> append(c)
+               }
+       }
+}
+
+/**
+ * Escapes special characters of a String for HTML output. Handles double quotes,
+ * greater than, less than, ampersand, and characters greater than eight bit.
+ */
+fun String.escapeHTML(): String {
+       return usingAppendable(Appendable::escapeHTML)
+}
+
+fun Appendable.toAttributeName(csq: CharSequence) {
+       csq.forEach {
+               if (it in 'A'..'Z') {
+                       append('-')
+                       append(it.lowercase())
+               } else {
+                       append(it)
+               }
+       }
+}
+
+fun String.toAttributeName(): String = usingAppendable(Appendable::toAttributeName)
+
+fun String.usingAppendable(function: Appendable.(CharSequence) -> Unit): String =
+       StringBuilder().also { it.function(this) }.toString()
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/RenderMode.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/RenderMode.kt
new file mode 100644 (file)
index 0000000..876345b
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg
+
+/**
+ * The mode to employ when rendering. Some Elements must render differently when used inline in HTML5 or in a
+ * standalone SVG file.
+ */
+enum class RenderMode {
+       /**
+        * Render as inline SVG designed to appear inline in HTML5.
+        */
+       INLINE,
+       
+       /**
+        * Render as an SVG `.svg` file format.
+        */
+       FILE
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/AttributeProperty.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/AttributeProperty.kt
new file mode 100644 (file)
index 0000000..4916a31
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.attributes
+
+import com.github.nwillc.ksvg.toAttributeName
+import kotlin.properties.ReadWriteProperty
+import kotlin.reflect.KProperty
+
+/**
+ * A property delegate to allow attributes to be rendered with a different name and to validate content by type.
+ * @param renamed The name to use when rendering the property.
+ * @param type The attribute type to use for validation.
+ */
+class AttributeProperty(
+       private val renamed: String? = null,
+       private val type: AttributeType = AttributeType.None
+) : ReadWriteProperty<Any?, String?> {
+       override operator fun getValue(thisRef: Any?, property: KProperty<*>): String? = if (thisRef is HasAttributes) {
+               thisRef.attributes[renamed ?: property.name.toAttributeName()]
+       } else {
+               null
+       }
+       
+       override operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String?) {
+               if (value != null && thisRef is HasAttributes) {
+                       if (thisRef.validation)
+                               type.verify(value)
+                       thisRef.attributes[renamed ?: property.name.toAttributeName()] = value
+               }
+       }
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/AttributeType.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/AttributeType.kt
new file mode 100644 (file)
index 0000000..2b7670d
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.attributes
+
+/**
+ *  An enumeration of attribute types and how to verify if a value is of this type.
+ */
+enum class AttributeType {
+       /**
+        * No validations will be performed on type none.
+        */
+       None,
+       
+       /**
+        * A length value, a number and optional unit.
+        */
+       Length {
+               override fun verify(value: String) {
+                       require(value matches length) { "Value ($value) is not a valid length or percentage: $length" }
+               }
+       },
+       
+       /**
+        * A length or percentage, a number and optional unit or percent sign.
+        */
+       LengthOrPercentage {
+               override fun verify(value: String) {
+                       require(value matches lengthPercent) {
+                               "Value ($value) is not a valid length or percentage: $lengthPercent"
+                       }
+               }
+       },
+       
+       /**
+        * A list of numbers separated by white space or commas.
+        */
+       NumberList {
+               override fun verify(value: String) {
+                       require(value matches numberList) { "Value ($value) is not a valid number list: $number" }
+               }
+       },
+       
+       /**
+        * Fill rule
+        */
+       FillRule {
+               override fun verify(value: String) {
+                       require(value matches fillRule) { "Value ($value) is not a valid `fill-rule` value: $fillRule" }
+               }
+       },
+       
+       /**
+        * Stroke linecap
+        */
+       StrokeLinecap {
+               override fun verify(value: String) {
+                       require(value matches strokeLinecap) { "Value ($value) is not a valid `stroke-linecap` value: $strokeLinecap" }
+               }
+       },
+       
+       /**
+        * Stroke linejoin
+        */
+       StrokeLinejoin {
+               override fun verify(value: String) {
+                       require(value matches strokeLinejoin) { "Value ($value) is not a valid `stroke-linejoin` value: $strokeLinejoin" }
+               }
+       },
+       
+       /**
+        * Text anchor
+        */
+       TextAnchor {
+               override fun verify(value: String) {
+                       require(value matches textAnchor) { "Value ($value) is not a valid `text-anchor` value: $textAnchor" }
+               }
+       },
+       
+       /**
+        * Any non empty character string without whitespace.
+        */
+       IdName {
+               override fun verify(value: String) {
+                       require(value matches idName) { "Value ($value) is not a valid id: $idName" }
+               }
+       },
+       
+       /**
+        * A relative URL by id URL.
+        */
+       RelativeURL {
+               override fun verify(value: String) {
+                       require(value matches relativeUrl) { "Value ($value) is not a valid id url: $relativeUrl" }
+               }
+       },
+       
+       /**
+        * A set of commands and coordinates.
+        */
+       Path {
+               override fun verify(value: String) {
+                       require(value matches path) { "Value ($value) is not a valid path: $path" }
+               }
+       },
+       
+       /**
+        * CSS class names work imperfectly in some browsers so warn about them.
+        */
+       CssClass;
+       
+       /**
+        * Constants.
+        */
+       private companion object {
+               private val number = Regex("[+-]?[0-9]*.?[0-9]+")
+               private val separator = Regex("\\s*,?\\s+")
+               private const val LENGTH_UNITS = "em|rem|ex|px|in|cm|mm|pt|pc"
+               private val length = Regex("$number($LENGTH_UNITS)?")
+               private val lengthPercent = Regex("$number($LENGTH_UNITS|%)?")
+               private val numberList = Regex("($number($separator)?)+")
+               private val fillRule = Regex("nonzero|evenodd")
+               private val strokeLinecap = Regex("butt|round|square")
+               private val strokeLinejoin = Regex("miter|round|bevel")
+               private val textAnchor = Regex("start|middle|end")
+               private val idName = Regex("\\S+")
+               private val relative = Regex("#$idName")
+               private val relativeUrl = Regex("url\\($relative\\)")
+               private val path = Regex("(($number)|[\\smMlLhHvVcCsSqQtTaAzZ])+")
+       }
+       
+       /**
+        * Verify a value is of the AttributeType.
+        */
+       open fun verify(value: String) { /* No verifications by default */
+       }
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasAttributes.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasAttributes.kt
new file mode 100644 (file)
index 0000000..592f787
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.attributes
+
+import com.github.nwillc.ksvg.RenderMode
+
+/**
+ * This interface describes how SVG handles attributes.
+ */
+interface HasAttributes {
+       /**
+        * The attributes are simply labels with associated values.
+        */
+       val attributes: MutableMap<String, String>
+       
+       /**
+        * Should we attempt to validated values correctness when assign them?
+        */
+       var validation: Boolean
+       
+       /**
+        * Return the attribute map, with possible processing based on the renderMode.
+        * @param renderMode which rendering mode the attributes are being accessed for.
+        */
+       fun getAttributes(renderMode: RenderMode): Map<String, String>
+       
+       /**
+        * All things that can have attributes can have an id attribute.
+        */
+       var id: String?
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasAttributesImpl.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasAttributesImpl.kt
new file mode 100644 (file)
index 0000000..7212c2c
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.attributes
+
+import com.github.nwillc.ksvg.RenderMode
+
+/**
+ * A basic implementation of HasAttributes.
+ */
+open class HasAttributesImpl(override var validation: Boolean) : HasAttributes {
+       override val attributes: MutableMap<String, String> = hashMapOf()
+       override var id: String? by AttributeProperty(type = AttributeType.IdName)
+       override fun getAttributes(renderMode: RenderMode) = attributes
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasClipPath.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasClipPath.kt
new file mode 100644 (file)
index 0000000..eb7509c
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.attributes
+
+/**
+ * An Element has a clip path.
+ */
+interface HasClipPath {
+       /**
+        * The clip path ID.
+        */
+       var clipPath: String?
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasClipPathImpl.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasClipPathImpl.kt
new file mode 100644 (file)
index 0000000..a4b674f
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.attributes
+
+/**
+ * A basic implementation of HasDimensions.
+ */
+class HasClipPathImpl(hasAttributes: HasAttributes) : HasClipPath, HasAttributes by hasAttributes {
+       override var clipPath: String? by AttributeProperty(type = AttributeType.RelativeURL)
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasDimensions.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasDimensions.kt
new file mode 100644 (file)
index 0000000..47e5eb6
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.attributes
+
+/**
+ * An Element has height and width dimensions.
+ */
+interface HasDimensions {
+       /**
+        * The height dimension.
+        */
+       var height: String?
+       
+       /**
+        * The width dimension.
+        */
+       var width: String?
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasDimensionsImpl.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasDimensionsImpl.kt
new file mode 100644 (file)
index 0000000..5e569a9
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.attributes
+
+/**
+ * A basic implementation of HasDimensions.
+ */
+class HasDimensionsImpl(hasAttributes: HasAttributes) : HasDimensions, HasAttributes by hasAttributes {
+       override var height: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
+       override var width: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasFill.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasFill.kt
new file mode 100644 (file)
index 0000000..3bbacff
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.attributes
+
+/**
+ * An Element can have a fill color.
+ */
+interface HasFill {
+       /**
+        * The fill color.
+        */
+       var fill: String?
+       
+       /**
+        * The fill rule.
+        */
+       var fillRule: String?
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasFillImpl.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasFillImpl.kt
new file mode 100644 (file)
index 0000000..21f3b45
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.attributes
+
+/**
+ * A basic implementation of HasFill.
+ */
+class HasFillImpl(hasAttributes: HasAttributes) : HasFill, HasAttributes by hasAttributes {
+       override var fill: String? by AttributeProperty()
+       override var fillRule: String? by AttributeProperty(type = AttributeType.FillRule)
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasOrigin.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasOrigin.kt
new file mode 100644 (file)
index 0000000..0a5ffd9
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.attributes
+
+/**
+ * An Element has x,y origin.
+ */
+interface HasOrigin {
+       /**
+        * Origin's X coordinate.
+        */
+       var x: String?
+       
+       /**
+        * Origin's Y coordinate.
+        */
+       var y: String?
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasOriginImpl.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasOriginImpl.kt
new file mode 100644 (file)
index 0000000..59a97da
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.attributes
+
+/**
+ * A Basic implementation of HasOrigin.
+ */
+class HasOriginImpl(hasAttributes: HasAttributes) : HasOrigin, HasAttributes by hasAttributes {
+       override var x: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
+       override var y: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasStroke.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasStroke.kt
new file mode 100644 (file)
index 0000000..0dd59a8
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.attributes
+
+/**
+ * An Element has a stroke associated.
+ */
+interface HasStroke {
+       /**
+        * The stroke color.
+        */
+       var stroke: String?
+       
+       /**
+        * The stroke width.
+        */
+       var strokeWidth: String?
+       
+       /**
+        * The stroke dash array.
+        */
+       var strokeDashArray: String?
+       
+       /**
+        * The stroke line cap.
+        */
+       var strokeLinecap: String?
+       
+       /**
+        * The stroke line join.
+        */
+       var strokeLinejoin: String?
+       
+       /**
+        * The paint order.
+        */
+       var paintOrder: String?
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasStrokeImpl.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/attributes/HasStrokeImpl.kt
new file mode 100644 (file)
index 0000000..d90ab5b
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.attributes
+
+/**
+ * A basic implementation of HasStroke.
+ */
+class HasStrokeImpl(hasAttributes: HasAttributes) : HasStroke, HasAttributes by hasAttributes {
+       override var stroke: String? by AttributeProperty()
+       override var strokeWidth: String? by AttributeProperty()
+       override var strokeDashArray: String? by AttributeProperty(type = AttributeType.NumberList)
+       override var strokeLinecap: String? by AttributeProperty(type = AttributeType.StrokeLinecap)
+       override var strokeLinejoin: String? by AttributeProperty(type = AttributeType.StrokeLinejoin)
+       override var paintOrder: String? by AttributeProperty()
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/A.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/A.kt
new file mode 100644 (file)
index 0000000..ced4aea
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+import com.github.nwillc.ksvg.RenderMode
+import com.github.nwillc.ksvg.attributes.AttributeProperty
+
+/**
+ * An SVG A reference element.
+ */
+class A(validation: Boolean = false) : Element("a", validation) {
+       /**
+        * The reference URL.
+        */
+       var href: String? by AttributeProperty()
+       
+       /**
+        * Create a rect element inside the reference.
+        */
+       fun rect(block: RECT.() -> Unit): RECT = add(RECT(validation), block)
+       
+       /**
+        * Create a text element inside the reference.
+        */
+       fun text(block: TEXT.() -> Unit): TEXT = add(TEXT(validation), block)
+       
+       override fun getAttributes(renderMode: RenderMode): Map<String, String> =
+               if (renderMode == RenderMode.INLINE) HashMap(attributes).apply {
+                       remove("href")?.let { href ->
+                               put("xlink:href", href)
+                       }
+               } else {
+                       attributes
+               }
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/CIRCLE.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/CIRCLE.kt
new file mode 100644 (file)
index 0000000..17b3f43
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+import com.github.nwillc.ksvg.attributes.AttributeProperty
+import com.github.nwillc.ksvg.attributes.AttributeType
+
+/**
+ * An SVG circle element.
+ */
+class CIRCLE(validation: Boolean = false) : Region("circle", validation) {
+       /**
+        * The x coordinate of the circle's center.
+        */
+       var cx: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
+       
+       /**
+        * The r coordinate of the circle's center.
+        */
+       var cy: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
+       
+       /**
+        * The radius or the circle.
+        */
+       var r: String? by AttributeProperty(type = AttributeType.Length)
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/CLIPPATH.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/CLIPPATH.kt
new file mode 100644 (file)
index 0000000..998a819
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+/**
+ * An SVG container element used to group other SVG elements.
+ */
+class CLIPPATH(id: String, validation: Boolean = false) : Container("clipPath", validation) {
+       init {
+               this.id = id
+       }
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/Container.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/Container.kt
new file mode 100644 (file)
index 0000000..5606352
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+import com.github.nwillc.ksvg.attributes.HasAttributes
+import com.github.nwillc.ksvg.attributes.HasAttributesImpl
+
+/**
+ * An abstract container element which provides factories for general sub elements.
+ */
+abstract class Container(
+       name: String,
+       validation: Boolean,
+       hasAttributes: HasAttributes = HasAttributesImpl(validation)
+) : Element(name, validation, hasAttributes) {
+       /**
+        * Create a rect element in this svg.
+        */
+       fun rect(block: RECT.() -> Unit): RECT = add(RECT(validation), block)
+       
+       /**
+        * Create a text element in this svg.
+        */
+       fun text(block: TEXT.() -> Unit): TEXT = add(TEXT(validation), block)
+       
+       /**
+        * Create a circle element in this svg.
+        */
+       fun circle(block: CIRCLE.() -> Unit): CIRCLE = add(CIRCLE(validation), block)
+       
+       /**
+        * Create a polygon element in this svg.
+        */
+       fun polygon(block: POLYGON.() -> Unit): POLYGON = add(POLYGON(validation), block)
+       
+       /**
+        * Create a line element in this svg.
+        */
+       fun line(block: LINE.() -> Unit): LINE = add(LINE(validation), block)
+       
+       /**
+        * Create a reference element in this svg.
+        */
+       fun a(block: A.() -> Unit): A = add(A(validation), block)
+       
+       /**
+        * Create a path element in this svg.
+        */
+       fun path(block: PATH.() -> Unit): PATH = add(PATH(validation), block)
+       
+       /**
+        * Create an image element in this svg.
+        */
+       fun image(block: IMAGE.() -> Unit): IMAGE = add(IMAGE(validation), block)
+       
+       /**
+        * Create a group element in this svg.
+        */
+       fun g(block: G.() -> Unit): G = add(G(validation), block)
+       
+       /**
+        * Create a use element in this svg.
+        */
+       fun use(block: USE.() -> Unit): USE = add(USE(validation), block)
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/DEFS.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/DEFS.kt
new file mode 100644 (file)
index 0000000..6e34818
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+/**
+ * An SVG defs element which can define groups to be used later.
+ */
+class DEFS(validation: Boolean) : Element("defs", validation) {
+       /**
+        * Create a group element in this def.
+        */
+       fun g(block: G.() -> Unit): G = add(G(validation), block)
+       
+       /**
+        * Create a clipPath element in this def.
+        */
+       fun clipPath(id: String, block: CLIPPATH.() -> Unit): CLIPPATH = add(CLIPPATH(id, validation), block)
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/Element.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/Element.kt
new file mode 100644 (file)
index 0000000..636df6d
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+import com.github.nwillc.ksvg.RenderMode
+import com.github.nwillc.ksvg.attributes.AttributeProperty
+import com.github.nwillc.ksvg.attributes.AttributeType
+import com.github.nwillc.ksvg.attributes.HasAttributes
+import com.github.nwillc.ksvg.attributes.HasAttributesImpl
+import com.github.nwillc.ksvg.escapeHTML
+
+/**
+ * Abstract SVG named element with attributes and child elements.
+ * @param name The svg tag of the element.
+ * @param validation Should attribute and other validations be performed?
+ */
+@SvgTagMarker
+abstract class Element(
+       private val name: String,
+       validation: Boolean,
+       hasAttributes: HasAttributes = HasAttributesImpl(validation)
+) : HasAttributes by hasAttributes {
+       /**
+        * Child Element contained in this Element.
+        */
+       val children = arrayListOf<Element>()
+       
+       /**
+        * The CSS class.
+        */
+       var cssClass: String? by AttributeProperty("class", AttributeType.CssClass)
+       
+       /**
+        * The CSS transformation.
+        */
+       var transform: String? by AttributeProperty()
+       
+       /**
+        * Raw text body of the Element.
+        */
+       var body: String = ""
+       
+       /**
+        * Add a child element.
+        */
+       protected fun <E : Element> add(element: E, block: E.() -> Unit): E = element.also {
+               it.block()
+               children.add(it)
+       }
+       
+       /**
+        * Render the Element as SVG.
+        * @param appendable A Writer to append the SVG to.
+        * @param renderMode Should the Elements render for inline SVG or file SVG.
+        */
+       open fun render(appendable: Appendable, renderMode: RenderMode) {
+               appendable.append("<$name")
+               getAttributes(renderMode)
+                       .entries
+                       .sortedBy { it.key }
+                       .forEach { entry ->
+                               appendable.append(' ')
+                               appendable.append(entry.key)
+                               appendable.append("=\"")
+                               appendable.append(entry.value)
+                               appendable.append('"')
+                       }
+               if (!hasContent()) {
+                       appendable.append("/>\n")
+               } else {
+                       appendable.append('>')
+                       if (hasBody()) {
+                               appendable.escapeHTML(body)
+                       } else {
+                               appendable.append('\n')
+                       }
+                       children.forEach {
+                               it.render(appendable, renderMode)
+                       }
+                       appendable.append("</$name>\n")
+               }
+       }
+       
+       /**
+        * Has raw text body.
+        */
+       fun hasBody(): Boolean = body.isNotBlank()
+       
+       /**
+        * Has Children.
+        */
+       fun hasChildren(): Boolean = children.isNotEmpty()
+       
+       
+       /**
+        * Has any content, i.e. a body and/or children.
+        */
+       fun hasContent(): Boolean = hasBody() || hasChildren()
+       
+       /**
+        * Returns the rendered inline SVG as a String.
+        */
+       override fun toString(): String = StringBuilder().apply {
+               render(this, RenderMode.INLINE)
+       }.toString()
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/G.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/G.kt
new file mode 100644 (file)
index 0000000..18bb2d4
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+import com.github.nwillc.ksvg.attributes.HasAttributes
+import com.github.nwillc.ksvg.attributes.HasAttributesImpl
+import com.github.nwillc.ksvg.attributes.HasClipPath
+import com.github.nwillc.ksvg.attributes.HasClipPathImpl
+
+/**
+ * An SVG container element used to group other SVG elements.
+ */
+class G(validation: Boolean = false, hasAttributes: HasAttributes = HasAttributesImpl(validation)) : Container("g", validation, hasAttributes), HasClipPath by HasClipPathImpl(hasAttributes)
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/IMAGE.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/IMAGE.kt
new file mode 100644 (file)
index 0000000..6084a35
--- /dev/null
@@ -0,0 +1,11 @@
+package com.github.nwillc.ksvg.elements
+
+import com.github.nwillc.ksvg.attributes.*
+
+class IMAGE(validation: Boolean = false, hasAttributes: HasAttributes = HasAttributesImpl(validation)) :
+       Element("image", validation, hasAttributes),
+       HasOrigin by HasOriginImpl(hasAttributes),
+       HasDimensions by HasDimensionsImpl(hasAttributes),
+       HasClipPath by HasClipPathImpl(hasAttributes) {
+       var href: String? by AttributeProperty(type = AttributeType.None)
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/LINE.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/LINE.kt
new file mode 100644 (file)
index 0000000..e39f78c
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+import com.github.nwillc.ksvg.attributes.*
+
+/**
+ * An SVG line element.
+ */
+class LINE(validation: Boolean = false, hasAttributes: HasAttributes = HasAttributesImpl(validation)) :
+       Element("line", validation, hasAttributes),
+       HasStroke by HasStrokeImpl(hasAttributes) {
+       
+       /**
+        * The X1 coordinate of the line.
+        */
+       var x1: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
+       
+       /**
+        * The Y1 coordinate of the line.
+        */
+       var y1: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
+       
+       /**
+        * The X2 coordinate of the line.
+        */
+       var x2: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
+       
+       /**
+        * The Y2 coordinate of the line.
+        */
+       var y2: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/PATH.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/PATH.kt
new file mode 100644 (file)
index 0000000..677f24d
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+import com.github.nwillc.ksvg.attributes.AttributeProperty
+import com.github.nwillc.ksvg.attributes.AttributeType
+
+/**
+ * An SVG path element.
+ */
+class PATH(validation: Boolean = false) : Region("path", validation) {
+       /**
+        * The path definition.
+        */
+       var d: String? by AttributeProperty(type = AttributeType.Path)
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/POLYGON.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/POLYGON.kt
new file mode 100644 (file)
index 0000000..bfe89b9
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+import com.github.nwillc.ksvg.attributes.AttributeProperty
+import com.github.nwillc.ksvg.attributes.AttributeType
+
+/**
+ * An SVG polygon element.
+ */
+class POLYGON(validation: Boolean = false) : Region("polygon", validation) {
+       /**
+        * The points defining the x and y coordinates for each corner of the polygon.
+        */
+       var points: String? by AttributeProperty(type = AttributeType.Path)
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/RECT.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/RECT.kt
new file mode 100644 (file)
index 0000000..136701c
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+import com.github.nwillc.ksvg.attributes.*
+
+/**
+ * An SVG rect element.
+ */
+class RECT(validation: Boolean = false, hasAttributes: HasAttributes = HasAttributesImpl(validation)) :
+       Region("rect", validation, hasAttributes),
+       HasOrigin by HasOriginImpl(hasAttributes),
+       HasDimensions by HasDimensionsImpl(hasAttributes) {
+       /**
+        * Add a title to the rect.
+        */
+       fun title(block: TITLE.() -> Unit): TITLE = add(TITLE(validation), block)
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/Region.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/Region.kt
new file mode 100644 (file)
index 0000000..e595644
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+import com.github.nwillc.ksvg.attributes.*
+
+/**
+ * An abstract element that is a region and therefore has stroke and fill.
+ */
+abstract class Region(
+       name: String,
+       validation: Boolean,
+       hasAttributes: HasAttributes = HasAttributesImpl(validation)
+) :
+       Element(name, validation, hasAttributes),
+       HasStroke by HasStrokeImpl(hasAttributes),
+       HasFill by HasFillImpl(hasAttributes),
+       HasClipPath by HasClipPathImpl(hasAttributes)
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/STYLE.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/STYLE.kt
new file mode 100644 (file)
index 0000000..a0def8b
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+/**
+ * An SVG style element.
+ */
+class STYLE(validation: Boolean) : Element("style", validation)
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/SVG.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/SVG.kt
new file mode 100644 (file)
index 0000000..6c6cc98
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+import com.github.nwillc.ksvg.RenderMode
+import com.github.nwillc.ksvg.attributes.*
+
+/**
+ * The SVG element itself.
+ */
+class SVG(validation: Boolean = false, hasAttributes: HasAttributes = HasAttributesImpl(validation)) :
+       Container("svg", validation, hasAttributes),
+       HasDimensions by HasDimensionsImpl(hasAttributes) {
+       /**
+        * Top level functions.
+        */
+       companion object {
+               /**
+                * Create an SVG element.
+                */
+               inline fun svg(validation: Boolean = false, block: SVG.() -> Unit): SVG = SVG(validation).apply(block)
+       }
+       
+       /**
+        * The viewBox attribute.
+        */
+       var viewBox: String? by AttributeProperty("viewBox", AttributeType.NumberList)
+       
+       /**
+        * Create a group element in this svg.
+        */
+       fun defs(block: DEFS.() -> Unit): DEFS = add(DEFS(validation), block)
+       
+       /**
+        * Create a style element.
+        */
+       fun style(block: STYLE.() -> Unit): STYLE = add(STYLE(validation), block)
+       
+       override fun getAttributes(renderMode: RenderMode): Map<String, String> = if (renderMode == RenderMode.FILE) {
+               mutableMapOf(
+                       "xmlns" to "http://www.w3.org/2000/svg",
+                       "xmlns:xlink" to "http://www.w3.org/1999/xlink",
+               ).also {
+                       it.putAll(attributes)
+               }
+       } else {
+               super.getAttributes(renderMode)
+       }
+       
+       override fun render(appendable: Appendable, renderMode: RenderMode) {
+               if (renderMode == RenderMode.FILE) {
+                       appendable.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n")
+               }
+               super.render(appendable, renderMode)
+       }
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/SvgTagMarker.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/SvgTagMarker.kt
new file mode 100644 (file)
index 0000000..94bca6d
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+/**
+ * Indicates something is an SVG DSL marker.
+ */
+@DslMarker
+annotation class SvgTagMarker
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/TEXT.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/TEXT.kt
new file mode 100644 (file)
index 0000000..3749140
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+import com.github.nwillc.ksvg.attributes.*
+
+/**
+ * An SVG text element.
+ */
+class TEXT(validation: Boolean = false, hasAttributes: HasAttributes = HasAttributesImpl(validation)) :
+       Element("text", validation, hasAttributes),
+       HasOrigin by HasOriginImpl(hasAttributes),
+       HasFill by HasFillImpl(hasAttributes),
+       HasStroke by HasStrokeImpl(hasAttributes),
+       HasClipPath by HasClipPathImpl(hasAttributes) {
+       
+       /**
+        * The font size attributes.
+        */
+       var fontSize: String? by AttributeProperty(type = AttributeType.Length)
+       
+       /**
+        * The font family.
+        */
+       var fontFamily: String? by AttributeProperty()
+       
+       /**
+        * The textLength attribute.
+        */
+       var textLength: String? by AttributeProperty(renamed = "textLength", type = AttributeType.LengthOrPercentage)
+       
+       /**
+        * The text-anchor attribute.
+        */
+       var textAnchor: String? by AttributeProperty(type = AttributeType.TextAnchor)
+}
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/TITLE.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/TITLE.kt
new file mode 100644 (file)
index 0000000..20b18e5
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+/**
+ * An SVG title element.
+ */
+class TITLE(validation: Boolean = false) : Element("title", validation)
diff --git a/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/USE.kt b/externals/src/jsMain/kotlin/com/github/nwillc/ksvg/elements/USE.kt
new file mode 100644 (file)
index 0000000..01b0279
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2020, nwillc@gmail.com
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package com.github.nwillc.ksvg.elements
+
+import com.github.nwillc.ksvg.RenderMode
+import com.github.nwillc.ksvg.attributes.*
+
+/**
+ * An SVG use element.
+ */
+class USE(validation: Boolean = false, hasAttributes: HasAttributes = HasAttributesImpl(validation)) :
+       Element("use", validation, hasAttributes),
+       HasOrigin by HasOriginImpl(hasAttributes),
+       HasDimensions by HasDimensionsImpl(hasAttributes) {
+       
+       /**
+        * The reference URL.
+        */
+       var href: String? by AttributeProperty()
+       
+       override fun getAttributes(renderMode: RenderMode): Map<String, String> =
+               if (renderMode == RenderMode.INLINE) HashMap(attributes).apply {
+                       remove("href")?.let { href ->
+                               put("xlink:href", href)
+                       }
+               } else {
+                       attributes
+               }
+}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/HtmlUtils.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/HtmlUtils.kt
deleted file mode 100644 (file)
index 4ce81f4..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg
-
-internal const val EIGHT_BIT_START = 127.toChar()
-
-/**
- * Escapes special characters of an Appendable for HTML output. Handles double quotes,
- * greater than, less than, ampersand, and characters greater than eight bit.
- * @param csq A sequence of characters to HTML escape.
- */
-fun Appendable.escapeHTML(csq: CharSequence) {
-       for (c in csq) {
-               when {
-                       c > EIGHT_BIT_START || c == '"' || c == '<' || c == '>' || c == '&' -> {
-                               append("&#")
-                               append(c.code.toString())
-                               append(';')
-                       }
-                       
-                       else -> append(c)
-               }
-       }
-}
-
-/**
- * Escapes special characters of a String for HTML output. Handles double quotes,
- * greater than, less than, ampersand, and characters greater than eight bit.
- */
-fun String.escapeHTML(): String {
-       return usingAppendable(Appendable::escapeHTML)
-}
-
-fun Appendable.toAttributeName(csq: CharSequence) {
-       csq.forEach {
-               if (it in 'A'..'Z') {
-                       append('-')
-                       append(it.lowercase())
-               } else {
-                       append(it)
-               }
-       }
-}
-
-fun String.toAttributeName(): String = usingAppendable(Appendable::toAttributeName)
-
-fun String.usingAppendable(function: Appendable.(CharSequence) -> Unit): String =
-       StringBuilder().also { it.function(this) }.toString()
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/RenderMode.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/RenderMode.kt
deleted file mode 100644 (file)
index 876345b..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg
-
-/**
- * The mode to employ when rendering. Some Elements must render differently when used inline in HTML5 or in a
- * standalone SVG file.
- */
-enum class RenderMode {
-       /**
-        * Render as inline SVG designed to appear inline in HTML5.
-        */
-       INLINE,
-       
-       /**
-        * Render as an SVG `.svg` file format.
-        */
-       FILE
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/AttributeProperty.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/AttributeProperty.kt
deleted file mode 100644 (file)
index 4916a31..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.attributes
-
-import com.github.nwillc.ksvg.toAttributeName
-import kotlin.properties.ReadWriteProperty
-import kotlin.reflect.KProperty
-
-/**
- * A property delegate to allow attributes to be rendered with a different name and to validate content by type.
- * @param renamed The name to use when rendering the property.
- * @param type The attribute type to use for validation.
- */
-class AttributeProperty(
-       private val renamed: String? = null,
-       private val type: AttributeType = AttributeType.None
-) : ReadWriteProperty<Any?, String?> {
-       override operator fun getValue(thisRef: Any?, property: KProperty<*>): String? = if (thisRef is HasAttributes) {
-               thisRef.attributes[renamed ?: property.name.toAttributeName()]
-       } else {
-               null
-       }
-       
-       override operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String?) {
-               if (value != null && thisRef is HasAttributes) {
-                       if (thisRef.validation)
-                               type.verify(value)
-                       thisRef.attributes[renamed ?: property.name.toAttributeName()] = value
-               }
-       }
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/AttributeType.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/AttributeType.kt
deleted file mode 100644 (file)
index d9f135e..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.attributes
-
-/**
- *  An enumeration of attribute types and how to verify if a value is of this type.
- */
-enum class AttributeType {
-       /**
-        * No validations will be performed on type none.
-        */
-       None,
-       
-       /**
-        * A length value, a number and optional unit.
-        */
-       Length {
-               override fun verify(value: String) {
-                       require(value matches length) { "Value ($value) is not a valid length or percentage: $length" }
-               }
-       },
-       
-       /**
-        * A length or percentage, a number and optional unit or percent sign.
-        */
-       LengthOrPercentage {
-               override fun verify(value: String) {
-                       require(value matches lengthPercent) {
-                               "Value ($value) is not a valid length or percentage: $lengthPercent"
-                       }
-               }
-       },
-       
-       /**
-        * A list of numbers separated by white space or commas.
-        */
-       NumberList {
-               override fun verify(value: String) {
-                       require(value matches numberList) { "Value ($value) is not a valid number list: $number" }
-               }
-       },
-       
-       /**
-        * Fill rule
-        */
-       FillRule {
-               override fun verify(value: String) {
-                       require(value matches fillRule) { "Value ($value) is not a valid `fill-rule` value: $fillRule" }
-               }
-       },
-       
-       /**
-        * Stroke linecap
-        */
-       StrokeLinecap {
-               override fun verify(value: String) {
-                       require(value matches strokeLinecap) { "Value ($value) is not a valid `stroke-linecap` value: $strokeLinecap" }
-               }
-       },
-       
-       /**
-        * Stroke linejoin
-        */
-       StrokeLinejoin {
-               override fun verify(value: String) {
-                       require(value matches strokeLinejoin) { "Value ($value) is not a valid `stroke-linejoin` value: $strokeLinejoin" }
-               }
-       },
-       
-       /**
-        * Text anchor
-        */
-       TextAnchor {
-               override fun verify(value: String) {
-                       require(value matches textAnchor) { "Value ($value) is not a valid `text-anchor` value: $textAnchor" }
-               }
-       },
-       
-       /**
-        * Any non empty character string without whitespace.
-        */
-       IdName {
-               override fun verify(value: String) {
-                       require(value matches idName) { "Value ($value) is not a valid id: $idName" }
-               }
-       },
-       
-       /**
-        * A relative URL by id URL.
-        */
-       RelativeURL {
-               override fun verify(value: String) {
-                       require(value matches relativeUrl) { "Value ($value) is not a valid id url: $relativeUrl" }
-               }
-       },
-       
-       /**
-        * A set of commands and coordinates.
-        */
-       Path {
-               override fun verify(value: String) {
-                       require(value matches path) { "Value ($value) is not a valid path: $path" }
-               }
-       },
-       
-       /**
-        * CSS class names work imperfectly in some browsers so warn about them.
-        */
-       CssClass;
-       
-       /**
-        * Constants.
-        */
-       private companion object {
-               private val number = Regex("[+-]?[0-9]*.?[0-9]+")
-               private val separator = Regex("\\s*,?\\s+")
-               private const val lengthUnits = "em|rem|ex|px|in|cm|mm|pt|pc"
-               private val length = Regex("$number($lengthUnits)?")
-               private val lengthPercent = Regex("$number($lengthUnits|%)?")
-               private val numberList = Regex("($number($separator)?)+")
-               private val fillRule = Regex("nonzero|evenodd")
-               private val strokeLinecap = Regex("butt|round|square")
-               private val strokeLinejoin = Regex("miter|round|bevel")
-               private val textAnchor = Regex("start|middle|end")
-               private val idName = Regex("\\S+")
-               private val relative = Regex("#$idName")
-               private val relativeUrl = Regex("url\\($relative\\)")
-               private val path = Regex("(($number)|[\\smMlLhHvVcCsSqQtTaAzZ])+")
-       }
-       
-       /**
-        * Verify a value is of the AttributeType.
-        */
-       open fun verify(value: String) { /* No verifications by default */
-       }
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasAttributes.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasAttributes.kt
deleted file mode 100644 (file)
index 592f787..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.attributes
-
-import com.github.nwillc.ksvg.RenderMode
-
-/**
- * This interface describes how SVG handles attributes.
- */
-interface HasAttributes {
-       /**
-        * The attributes are simply labels with associated values.
-        */
-       val attributes: MutableMap<String, String>
-       
-       /**
-        * Should we attempt to validated values correctness when assign them?
-        */
-       var validation: Boolean
-       
-       /**
-        * Return the attribute map, with possible processing based on the renderMode.
-        * @param renderMode which rendering mode the attributes are being accessed for.
-        */
-       fun getAttributes(renderMode: RenderMode): Map<String, String>
-       
-       /**
-        * All things that can have attributes can have an id attribute.
-        */
-       var id: String?
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasAttributesImpl.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasAttributesImpl.kt
deleted file mode 100644 (file)
index 7212c2c..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.attributes
-
-import com.github.nwillc.ksvg.RenderMode
-
-/**
- * A basic implementation of HasAttributes.
- */
-open class HasAttributesImpl(override var validation: Boolean) : HasAttributes {
-       override val attributes: MutableMap<String, String> = hashMapOf()
-       override var id: String? by AttributeProperty(type = AttributeType.IdName)
-       override fun getAttributes(renderMode: RenderMode) = attributes
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasClipPath.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasClipPath.kt
deleted file mode 100644 (file)
index eb7509c..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.attributes
-
-/**
- * An Element has a clip path.
- */
-interface HasClipPath {
-       /**
-        * The clip path ID.
-        */
-       var clipPath: String?
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasClipPathImpl.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasClipPathImpl.kt
deleted file mode 100644 (file)
index a4b674f..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.attributes
-
-/**
- * A basic implementation of HasDimensions.
- */
-class HasClipPathImpl(hasAttributes: HasAttributes) : HasClipPath, HasAttributes by hasAttributes {
-       override var clipPath: String? by AttributeProperty(type = AttributeType.RelativeURL)
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasDimensions.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasDimensions.kt
deleted file mode 100644 (file)
index 47e5eb6..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.attributes
-
-/**
- * An Element has height and width dimensions.
- */
-interface HasDimensions {
-       /**
-        * The height dimension.
-        */
-       var height: String?
-       
-       /**
-        * The width dimension.
-        */
-       var width: String?
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasDimensionsImpl.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasDimensionsImpl.kt
deleted file mode 100644 (file)
index 5e569a9..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.attributes
-
-/**
- * A basic implementation of HasDimensions.
- */
-class HasDimensionsImpl(hasAttributes: HasAttributes) : HasDimensions, HasAttributes by hasAttributes {
-       override var height: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
-       override var width: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasFill.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasFill.kt
deleted file mode 100644 (file)
index 3bbacff..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.attributes
-
-/**
- * An Element can have a fill color.
- */
-interface HasFill {
-       /**
-        * The fill color.
-        */
-       var fill: String?
-       
-       /**
-        * The fill rule.
-        */
-       var fillRule: String?
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasFillImpl.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasFillImpl.kt
deleted file mode 100644 (file)
index 21f3b45..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.attributes
-
-/**
- * A basic implementation of HasFill.
- */
-class HasFillImpl(hasAttributes: HasAttributes) : HasFill, HasAttributes by hasAttributes {
-       override var fill: String? by AttributeProperty()
-       override var fillRule: String? by AttributeProperty(type = AttributeType.FillRule)
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasOrigin.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasOrigin.kt
deleted file mode 100644 (file)
index 0a5ffd9..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.attributes
-
-/**
- * An Element has x,y origin.
- */
-interface HasOrigin {
-       /**
-        * Origin's X coordinate.
-        */
-       var x: String?
-       
-       /**
-        * Origin's Y coordinate.
-        */
-       var y: String?
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasOriginImpl.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasOriginImpl.kt
deleted file mode 100644 (file)
index 59a97da..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.attributes
-
-/**
- * A Basic implementation of HasOrigin.
- */
-class HasOriginImpl(hasAttributes: HasAttributes) : HasOrigin, HasAttributes by hasAttributes {
-       override var x: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
-       override var y: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasStroke.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasStroke.kt
deleted file mode 100644 (file)
index 0dd59a8..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.attributes
-
-/**
- * An Element has a stroke associated.
- */
-interface HasStroke {
-       /**
-        * The stroke color.
-        */
-       var stroke: String?
-       
-       /**
-        * The stroke width.
-        */
-       var strokeWidth: String?
-       
-       /**
-        * The stroke dash array.
-        */
-       var strokeDashArray: String?
-       
-       /**
-        * The stroke line cap.
-        */
-       var strokeLinecap: String?
-       
-       /**
-        * The stroke line join.
-        */
-       var strokeLinejoin: String?
-       
-       /**
-        * The paint order.
-        */
-       var paintOrder: String?
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasStrokeImpl.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/attributes/HasStrokeImpl.kt
deleted file mode 100644 (file)
index d90ab5b..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.attributes
-
-/**
- * A basic implementation of HasStroke.
- */
-class HasStrokeImpl(hasAttributes: HasAttributes) : HasStroke, HasAttributes by hasAttributes {
-       override var stroke: String? by AttributeProperty()
-       override var strokeWidth: String? by AttributeProperty()
-       override var strokeDashArray: String? by AttributeProperty(type = AttributeType.NumberList)
-       override var strokeLinecap: String? by AttributeProperty(type = AttributeType.StrokeLinecap)
-       override var strokeLinejoin: String? by AttributeProperty(type = AttributeType.StrokeLinejoin)
-       override var paintOrder: String? by AttributeProperty()
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/A.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/A.kt
deleted file mode 100644 (file)
index ced4aea..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-import com.github.nwillc.ksvg.RenderMode
-import com.github.nwillc.ksvg.attributes.AttributeProperty
-
-/**
- * An SVG A reference element.
- */
-class A(validation: Boolean = false) : Element("a", validation) {
-       /**
-        * The reference URL.
-        */
-       var href: String? by AttributeProperty()
-       
-       /**
-        * Create a rect element inside the reference.
-        */
-       fun rect(block: RECT.() -> Unit): RECT = add(RECT(validation), block)
-       
-       /**
-        * Create a text element inside the reference.
-        */
-       fun text(block: TEXT.() -> Unit): TEXT = add(TEXT(validation), block)
-       
-       override fun getAttributes(renderMode: RenderMode): Map<String, String> =
-               if (renderMode == RenderMode.INLINE) HashMap(attributes).apply {
-                       remove("href")?.let { href ->
-                               put("xlink:href", href)
-                       }
-               } else {
-                       attributes
-               }
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/CIRCLE.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/CIRCLE.kt
deleted file mode 100644 (file)
index 17b3f43..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-import com.github.nwillc.ksvg.attributes.AttributeProperty
-import com.github.nwillc.ksvg.attributes.AttributeType
-
-/**
- * An SVG circle element.
- */
-class CIRCLE(validation: Boolean = false) : Region("circle", validation) {
-       /**
-        * The x coordinate of the circle's center.
-        */
-       var cx: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
-       
-       /**
-        * The r coordinate of the circle's center.
-        */
-       var cy: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
-       
-       /**
-        * The radius or the circle.
-        */
-       var r: String? by AttributeProperty(type = AttributeType.Length)
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/CLIPPATH.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/CLIPPATH.kt
deleted file mode 100644 (file)
index 998a819..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-/**
- * An SVG container element used to group other SVG elements.
- */
-class CLIPPATH(id: String, validation: Boolean = false) : Container("clipPath", validation) {
-       init {
-               this.id = id
-       }
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/Container.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/Container.kt
deleted file mode 100644 (file)
index 5606352..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-import com.github.nwillc.ksvg.attributes.HasAttributes
-import com.github.nwillc.ksvg.attributes.HasAttributesImpl
-
-/**
- * An abstract container element which provides factories for general sub elements.
- */
-abstract class Container(
-       name: String,
-       validation: Boolean,
-       hasAttributes: HasAttributes = HasAttributesImpl(validation)
-) : Element(name, validation, hasAttributes) {
-       /**
-        * Create a rect element in this svg.
-        */
-       fun rect(block: RECT.() -> Unit): RECT = add(RECT(validation), block)
-       
-       /**
-        * Create a text element in this svg.
-        */
-       fun text(block: TEXT.() -> Unit): TEXT = add(TEXT(validation), block)
-       
-       /**
-        * Create a circle element in this svg.
-        */
-       fun circle(block: CIRCLE.() -> Unit): CIRCLE = add(CIRCLE(validation), block)
-       
-       /**
-        * Create a polygon element in this svg.
-        */
-       fun polygon(block: POLYGON.() -> Unit): POLYGON = add(POLYGON(validation), block)
-       
-       /**
-        * Create a line element in this svg.
-        */
-       fun line(block: LINE.() -> Unit): LINE = add(LINE(validation), block)
-       
-       /**
-        * Create a reference element in this svg.
-        */
-       fun a(block: A.() -> Unit): A = add(A(validation), block)
-       
-       /**
-        * Create a path element in this svg.
-        */
-       fun path(block: PATH.() -> Unit): PATH = add(PATH(validation), block)
-       
-       /**
-        * Create an image element in this svg.
-        */
-       fun image(block: IMAGE.() -> Unit): IMAGE = add(IMAGE(validation), block)
-       
-       /**
-        * Create a group element in this svg.
-        */
-       fun g(block: G.() -> Unit): G = add(G(validation), block)
-       
-       /**
-        * Create a use element in this svg.
-        */
-       fun use(block: USE.() -> Unit): USE = add(USE(validation), block)
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/DEFS.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/DEFS.kt
deleted file mode 100644 (file)
index 6e34818..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-/**
- * An SVG defs element which can define groups to be used later.
- */
-class DEFS(validation: Boolean) : Element("defs", validation) {
-       /**
-        * Create a group element in this def.
-        */
-       fun g(block: G.() -> Unit): G = add(G(validation), block)
-       
-       /**
-        * Create a clipPath element in this def.
-        */
-       fun clipPath(id: String, block: CLIPPATH.() -> Unit): CLIPPATH = add(CLIPPATH(id, validation), block)
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/Element.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/Element.kt
deleted file mode 100644 (file)
index 636df6d..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-import com.github.nwillc.ksvg.RenderMode
-import com.github.nwillc.ksvg.attributes.AttributeProperty
-import com.github.nwillc.ksvg.attributes.AttributeType
-import com.github.nwillc.ksvg.attributes.HasAttributes
-import com.github.nwillc.ksvg.attributes.HasAttributesImpl
-import com.github.nwillc.ksvg.escapeHTML
-
-/**
- * Abstract SVG named element with attributes and child elements.
- * @param name The svg tag of the element.
- * @param validation Should attribute and other validations be performed?
- */
-@SvgTagMarker
-abstract class Element(
-       private val name: String,
-       validation: Boolean,
-       hasAttributes: HasAttributes = HasAttributesImpl(validation)
-) : HasAttributes by hasAttributes {
-       /**
-        * Child Element contained in this Element.
-        */
-       val children = arrayListOf<Element>()
-       
-       /**
-        * The CSS class.
-        */
-       var cssClass: String? by AttributeProperty("class", AttributeType.CssClass)
-       
-       /**
-        * The CSS transformation.
-        */
-       var transform: String? by AttributeProperty()
-       
-       /**
-        * Raw text body of the Element.
-        */
-       var body: String = ""
-       
-       /**
-        * Add a child element.
-        */
-       protected fun <E : Element> add(element: E, block: E.() -> Unit): E = element.also {
-               it.block()
-               children.add(it)
-       }
-       
-       /**
-        * Render the Element as SVG.
-        * @param appendable A Writer to append the SVG to.
-        * @param renderMode Should the Elements render for inline SVG or file SVG.
-        */
-       open fun render(appendable: Appendable, renderMode: RenderMode) {
-               appendable.append("<$name")
-               getAttributes(renderMode)
-                       .entries
-                       .sortedBy { it.key }
-                       .forEach { entry ->
-                               appendable.append(' ')
-                               appendable.append(entry.key)
-                               appendable.append("=\"")
-                               appendable.append(entry.value)
-                               appendable.append('"')
-                       }
-               if (!hasContent()) {
-                       appendable.append("/>\n")
-               } else {
-                       appendable.append('>')
-                       if (hasBody()) {
-                               appendable.escapeHTML(body)
-                       } else {
-                               appendable.append('\n')
-                       }
-                       children.forEach {
-                               it.render(appendable, renderMode)
-                       }
-                       appendable.append("</$name>\n")
-               }
-       }
-       
-       /**
-        * Has raw text body.
-        */
-       fun hasBody(): Boolean = body.isNotBlank()
-       
-       /**
-        * Has Children.
-        */
-       fun hasChildren(): Boolean = children.isNotEmpty()
-       
-       
-       /**
-        * Has any content, i.e. a body and/or children.
-        */
-       fun hasContent(): Boolean = hasBody() || hasChildren()
-       
-       /**
-        * Returns the rendered inline SVG as a String.
-        */
-       override fun toString(): String = StringBuilder().apply {
-               render(this, RenderMode.INLINE)
-       }.toString()
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/G.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/G.kt
deleted file mode 100644 (file)
index 18bb2d4..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-import com.github.nwillc.ksvg.attributes.HasAttributes
-import com.github.nwillc.ksvg.attributes.HasAttributesImpl
-import com.github.nwillc.ksvg.attributes.HasClipPath
-import com.github.nwillc.ksvg.attributes.HasClipPathImpl
-
-/**
- * An SVG container element used to group other SVG elements.
- */
-class G(validation: Boolean = false, hasAttributes: HasAttributes = HasAttributesImpl(validation)) : Container("g", validation, hasAttributes), HasClipPath by HasClipPathImpl(hasAttributes)
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/IMAGE.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/IMAGE.kt
deleted file mode 100644 (file)
index 6084a35..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.github.nwillc.ksvg.elements
-
-import com.github.nwillc.ksvg.attributes.*
-
-class IMAGE(validation: Boolean = false, hasAttributes: HasAttributes = HasAttributesImpl(validation)) :
-       Element("image", validation, hasAttributes),
-       HasOrigin by HasOriginImpl(hasAttributes),
-       HasDimensions by HasDimensionsImpl(hasAttributes),
-       HasClipPath by HasClipPathImpl(hasAttributes) {
-       var href: String? by AttributeProperty(type = AttributeType.None)
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/LINE.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/LINE.kt
deleted file mode 100644 (file)
index e39f78c..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-import com.github.nwillc.ksvg.attributes.*
-
-/**
- * An SVG line element.
- */
-class LINE(validation: Boolean = false, hasAttributes: HasAttributes = HasAttributesImpl(validation)) :
-       Element("line", validation, hasAttributes),
-       HasStroke by HasStrokeImpl(hasAttributes) {
-       
-       /**
-        * The X1 coordinate of the line.
-        */
-       var x1: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
-       
-       /**
-        * The Y1 coordinate of the line.
-        */
-       var y1: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
-       
-       /**
-        * The X2 coordinate of the line.
-        */
-       var x2: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
-       
-       /**
-        * The Y2 coordinate of the line.
-        */
-       var y2: String? by AttributeProperty(type = AttributeType.LengthOrPercentage)
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/PATH.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/PATH.kt
deleted file mode 100644 (file)
index 677f24d..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-import com.github.nwillc.ksvg.attributes.AttributeProperty
-import com.github.nwillc.ksvg.attributes.AttributeType
-
-/**
- * An SVG path element.
- */
-class PATH(validation: Boolean = false) : Region("path", validation) {
-       /**
-        * The path definition.
-        */
-       var d: String? by AttributeProperty(type = AttributeType.Path)
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/POLYGON.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/POLYGON.kt
deleted file mode 100644 (file)
index bfe89b9..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-import com.github.nwillc.ksvg.attributes.AttributeProperty
-import com.github.nwillc.ksvg.attributes.AttributeType
-
-/**
- * An SVG polygon element.
- */
-class POLYGON(validation: Boolean = false) : Region("polygon", validation) {
-       /**
-        * The points defining the x and y coordinates for each corner of the polygon.
-        */
-       var points: String? by AttributeProperty(type = AttributeType.Path)
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/RECT.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/RECT.kt
deleted file mode 100644 (file)
index 136701c..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-import com.github.nwillc.ksvg.attributes.*
-
-/**
- * An SVG rect element.
- */
-class RECT(validation: Boolean = false, hasAttributes: HasAttributes = HasAttributesImpl(validation)) :
-       Region("rect", validation, hasAttributes),
-       HasOrigin by HasOriginImpl(hasAttributes),
-       HasDimensions by HasDimensionsImpl(hasAttributes) {
-       /**
-        * Add a title to the rect.
-        */
-       fun title(block: TITLE.() -> Unit): TITLE = add(TITLE(validation), block)
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/Region.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/Region.kt
deleted file mode 100644 (file)
index e595644..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-import com.github.nwillc.ksvg.attributes.*
-
-/**
- * An abstract element that is a region and therefore has stroke and fill.
- */
-abstract class Region(
-       name: String,
-       validation: Boolean,
-       hasAttributes: HasAttributes = HasAttributesImpl(validation)
-) :
-       Element(name, validation, hasAttributes),
-       HasStroke by HasStrokeImpl(hasAttributes),
-       HasFill by HasFillImpl(hasAttributes),
-       HasClipPath by HasClipPathImpl(hasAttributes)
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/STYLE.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/STYLE.kt
deleted file mode 100644 (file)
index a0def8b..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-/**
- * An SVG style element.
- */
-class STYLE(validation: Boolean) : Element("style", validation)
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/SVG.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/SVG.kt
deleted file mode 100644 (file)
index 6c6cc98..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-import com.github.nwillc.ksvg.RenderMode
-import com.github.nwillc.ksvg.attributes.*
-
-/**
- * The SVG element itself.
- */
-class SVG(validation: Boolean = false, hasAttributes: HasAttributes = HasAttributesImpl(validation)) :
-       Container("svg", validation, hasAttributes),
-       HasDimensions by HasDimensionsImpl(hasAttributes) {
-       /**
-        * Top level functions.
-        */
-       companion object {
-               /**
-                * Create an SVG element.
-                */
-               inline fun svg(validation: Boolean = false, block: SVG.() -> Unit): SVG = SVG(validation).apply(block)
-       }
-       
-       /**
-        * The viewBox attribute.
-        */
-       var viewBox: String? by AttributeProperty("viewBox", AttributeType.NumberList)
-       
-       /**
-        * Create a group element in this svg.
-        */
-       fun defs(block: DEFS.() -> Unit): DEFS = add(DEFS(validation), block)
-       
-       /**
-        * Create a style element.
-        */
-       fun style(block: STYLE.() -> Unit): STYLE = add(STYLE(validation), block)
-       
-       override fun getAttributes(renderMode: RenderMode): Map<String, String> = if (renderMode == RenderMode.FILE) {
-               mutableMapOf(
-                       "xmlns" to "http://www.w3.org/2000/svg",
-                       "xmlns:xlink" to "http://www.w3.org/1999/xlink",
-               ).also {
-                       it.putAll(attributes)
-               }
-       } else {
-               super.getAttributes(renderMode)
-       }
-       
-       override fun render(appendable: Appendable, renderMode: RenderMode) {
-               if (renderMode == RenderMode.FILE) {
-                       appendable.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n")
-               }
-               super.render(appendable, renderMode)
-       }
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/SvgTagMarker.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/SvgTagMarker.kt
deleted file mode 100644 (file)
index 94bca6d..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-/**
- * Indicates something is an SVG DSL marker.
- */
-@DslMarker
-annotation class SvgTagMarker
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/TEXT.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/TEXT.kt
deleted file mode 100644 (file)
index 3749140..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-import com.github.nwillc.ksvg.attributes.*
-
-/**
- * An SVG text element.
- */
-class TEXT(validation: Boolean = false, hasAttributes: HasAttributes = HasAttributesImpl(validation)) :
-       Element("text", validation, hasAttributes),
-       HasOrigin by HasOriginImpl(hasAttributes),
-       HasFill by HasFillImpl(hasAttributes),
-       HasStroke by HasStrokeImpl(hasAttributes),
-       HasClipPath by HasClipPathImpl(hasAttributes) {
-       
-       /**
-        * The font size attributes.
-        */
-       var fontSize: String? by AttributeProperty(type = AttributeType.Length)
-       
-       /**
-        * The font family.
-        */
-       var fontFamily: String? by AttributeProperty()
-       
-       /**
-        * The textLength attribute.
-        */
-       var textLength: String? by AttributeProperty(renamed = "textLength", type = AttributeType.LengthOrPercentage)
-       
-       /**
-        * The text-anchor attribute.
-        */
-       var textAnchor: String? by AttributeProperty(type = AttributeType.TextAnchor)
-}
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/TITLE.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/TITLE.kt
deleted file mode 100644 (file)
index 20b18e5..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-/**
- * An SVG title element.
- */
-class TITLE(validation: Boolean = false) : Element("title", validation)
diff --git a/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/USE.kt b/src/mapMain/kotlin/com/github/nwillc/ksvg/elements/USE.kt
deleted file mode 100644 (file)
index 01b0279..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2020, nwillc@gmail.com
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-package com.github.nwillc.ksvg.elements
-
-import com.github.nwillc.ksvg.RenderMode
-import com.github.nwillc.ksvg.attributes.*
-
-/**
- * An SVG use element.
- */
-class USE(validation: Boolean = false, hasAttributes: HasAttributes = HasAttributesImpl(validation)) :
-       Element("use", validation, hasAttributes),
-       HasOrigin by HasOriginImpl(hasAttributes),
-       HasDimensions by HasDimensionsImpl(hasAttributes) {
-       
-       /**
-        * The reference URL.
-        */
-       var href: String? by AttributeProperty()
-       
-       override fun getAttributes(renderMode: RenderMode): Map<String, String> =
-               if (renderMode == RenderMode.INLINE) HashMap(attributes).apply {
-                       remove("href")?.let { href ->
-                               put("xlink:href", href)
-                       }
-               } else {
-                       attributes
-               }
-}