From cb8867af2e82ae45d988467107c16d3257ec765e Mon Sep 17 00:00:00 2001 From: Timo Bryant Date: Fri, 5 Jan 2024 21:56:05 +0100 Subject: [PATCH] korge: add rotation --- .../kotlin/de/itkl/documentViewerKorge/main.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/documentViewerKorge/src/jvmMain/kotlin/de/itkl/documentViewerKorge/main.kt b/apps/documentViewerKorge/src/jvmMain/kotlin/de/itkl/documentViewerKorge/main.kt index 90f4d11..ca38ef0 100644 --- a/apps/documentViewerKorge/src/jvmMain/kotlin/de/itkl/documentViewerKorge/main.kt +++ b/apps/documentViewerKorge/src/jvmMain/kotlin/de/itkl/documentViewerKorge/main.kt @@ -34,6 +34,7 @@ class ViewDocument(private val document: Document) : Scene() { var scaleFactor = 0.5 var offset = Point(0.0,0.0) val moveFactor = 50.0 + var rotationFactor = 0.0 scale(scaleFactor) suspend fun zoom(amount: Double) { @@ -60,6 +61,15 @@ class ViewDocument(private val document: Document) : Scene() { easing = Easing.EASE_IN_OUT) } + suspend fun rotateBy(amount: Double){ + rotationFactor += amount + tween( + this@sceneMain::rotation[rotationFactor.degrees], + time = 0.1.seconds, + easing = Easing.EASE_IN_OUT + ) + } + keys { down { key -> when (key.key) { @@ -69,6 +79,8 @@ class ViewDocument(private val document: Document) : Scene() { Key.DOWN -> moveY(-moveFactor) Key.RIGHT -> moveX(moveFactor) Key.LEFT -> moveX(-moveFactor) + Key.E -> rotateBy(10.0) + Key.R -> rotateBy(-10.0) else -> {} } }