All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.PathElement.kt Maven / Gradle / Ivy

There is a newer version: 0.19.1
Show newest version
package com.juul.krayon.element

import com.juul.krayon.kanvas.Kanvas
import com.juul.krayon.kanvas.Paint
import com.juul.krayon.kanvas.Path

public class PathElement : Element(), Interactable {

    override val tag: String get() = "path"

    public var path: Path by attributes.withDefault { 0f }
    public var paint: Paint by attributes.withDefault { DEFAULT_STROKE }
    override var onClick: ((PathElement) -> Unit)? by attributes.withDefault { null }

    override fun  draw(canvas: Kanvas) {
        canvas.drawPath(canvas.buildPath(path), paint)
    }

    override fun getInteractionPath(): Path = path

    public companion object : ElementBuilder, ElementSelector {
        override fun build(): PathElement = PathElement()
        override fun trySelect(element: Element): PathElement? = element as? PathElement
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy