From 11b278fc81b7778eeca10bde19ba75ff9e537303 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Thu, 18 Aug 2022 18:47:06 +0300 Subject: [PATCH] Frodo goes to Mordor (directly) --- demo/scheme/src/jvmMain/kotlin/Main.kt | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/demo/scheme/src/jvmMain/kotlin/Main.kt b/demo/scheme/src/jvmMain/kotlin/Main.kt index 8803fea..6e5cc86 100644 --- a/demo/scheme/src/jvmMain/kotlin/Main.kt +++ b/demo/scheme/src/jvmMain/kotlin/Main.kt @@ -3,11 +3,15 @@ import androidx.compose.desktop.ui.tooling.preview.Preview import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.window.Window import androidx.compose.ui.window.application import center.sciprog.maps.scheme.* +import kotlinx.coroutines.delay +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch @Composable @Preview @@ -20,6 +24,7 @@ fun App() { 1f ) } + val scope = rememberCoroutineScope() SchemeView( @@ -33,9 +38,24 @@ fun App() { ) { background(painterResource("middle-earth.jpg")) circle(410.52737 to 868.7676, color = Color.Blue) - text(410.52737 to 868.7676,"Shire", color = Color.Blue) + text(410.52737 to 868.7676, "Shire", color = Color.Blue) circle(1132.0881 to 394.99127, color = Color.Red) - text(1132.0881 to 394.99127, "Ordruin",color = Color.Red) + text(1132.0881 to 394.99127, "Ordruin", color = Color.Red) + + val hobbitId = circle(410.52737 to 868.7676) + + scope.launch { + var t = 0.0 + while (isActive) { + val x = 410.52737 + t * (1132.0881 - 410.52737) + val y = 868.7676 + t * (394.99127 - 868.7676) + circle(x to y, color = Color.Green, id = hobbitId) + delay(100) + t += 0.005 + if (t >= 1.0) t = 0.0 + } + } + } } }