commonMain.KanvasElement.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of element Show documentation
Show all versions of element Show documentation
A collection of drawing/charting utilities
package com.juul.krayon.element
import com.juul.krayon.kanvas.Kanvas
/** Breakaway [Element] allowing for raw [Kanvas] drawing. */
public class KanvasElement : Element() {
override val tag: String get() = "kanvas"
public var onDraw: (Kanvas.() -> Unit)? by attributes.withDefault { null }
override fun draw(kanvas: Kanvas) {
val callback = onDraw
if (callback != null) {
with(kanvas) {
callback()
}
}
}
public companion object : ElementBuilder, ElementSelector {
override fun build(): KanvasElement = KanvasElement()
override fun trySelect(element: Element): KanvasElement? = element as? KanvasElement
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy