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

commonMain.TransformElement.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.Transform
import com.juul.krayon.kanvas.withTransform

public class TransformElement : Element() {

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

    public var transform: Transform by attributes.withDefault { Transform.Translate() }

    override fun draw(kanvas: Kanvas) {
        kanvas.withTransform(transform) {
            children.forEach { it.draw(kanvas) }
        }
    }

    public companion object : ElementBuilder, ElementSelector {
        override fun build(): TransformElement = TransformElement()

        override fun trySelect(element: Element): TransformElement? = element as? TransformElement
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy