-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from SciProgCentre/dev
0.3.0
- Loading branch information
Showing
114 changed files
with
1,767 additions
and
1,423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
build/ | ||
.gradle/ | ||
.idea/ | ||
.kotlin | ||
/*.iml | ||
|
||
mapCache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Module maps-wasm | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl | ||
|
||
plugins { | ||
kotlin("multiplatform") | ||
alias(spclibs.plugins.compose.compiler) | ||
alias(spclibs.plugins.compose.jb) | ||
} | ||
|
||
//val ktorVersion: String by rootProject.extra | ||
|
||
kotlin { | ||
@OptIn(ExperimentalWasmDsl::class) | ||
wasmJs { | ||
browser() | ||
binaries.executable() | ||
} | ||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) | ||
api(compose.components.resources) | ||
} | ||
} | ||
|
||
wasmJsMain { | ||
dependencies { | ||
implementation(projects.mapsKtScheme) | ||
} | ||
} | ||
} | ||
} | ||
|
||
compose { | ||
web { | ||
|
||
} | ||
} |
Binary file added
BIN
+469 KB
demo/maps-wasm/src/commonMain/composeResources/drawable/middle-earth.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
@file:OptIn(ExperimentalComposeUiApi::class, ExperimentalResourceApi::class) | ||
|
||
import androidx.compose.runtime.* | ||
import androidx.compose.ui.ExperimentalComposeUiApi | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.window.CanvasBasedWindow | ||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.isActive | ||
import kotlinx.coroutines.launch | ||
import org.jetbrains.compose.resources.ExperimentalResourceApi | ||
import org.jetbrains.compose.resources.painterResource | ||
import space.kscience.kmath.geometry.Angle | ||
import space.kscience.maps.features.FeatureGroup | ||
import space.kscience.maps.features.ViewConfig | ||
import space.kscience.maps.features.ViewPoint | ||
import space.kscience.maps.features.color | ||
import space.kscience.maps.scheme.* | ||
import space.kscience.maps_wasm.generated.resources.Res | ||
import space.kscience.maps_wasm.generated.resources.middle_earth | ||
|
||
|
||
@Composable | ||
fun App() { | ||
|
||
val scope = rememberCoroutineScope() | ||
|
||
|
||
val features: FeatureGroup<XY> = FeatureGroup.remember(XYCoordinateSpace) { | ||
background(1600f, 1200f) { | ||
painterResource(Res.drawable.middle_earth) | ||
} | ||
circle(410.52737 to 868.7676).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) | ||
arc(center = 1132.0881 to 394.99127, radius = 20f, startAngle = Angle.zero, Angle.piTimes2) | ||
|
||
//circle(410.52737 to 868.7676, id = "hobbit") | ||
|
||
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, id = "hobbit").color(Color.Green) | ||
delay(100) | ||
t += 0.005 | ||
if (t >= 1.0) t = 0.0 | ||
} | ||
} | ||
} | ||
|
||
val initialViewPoint: ViewPoint<XY> = remember { | ||
features.getBoundingBox(1f)?.computeViewPoint() ?: XYViewPoint(XY(0f, 0f)) | ||
} | ||
|
||
var viewPoint: ViewPoint<XY> by remember { mutableStateOf(initialViewPoint) } | ||
|
||
val mapState: XYCanvasState = XYCanvasState.remember( | ||
ViewConfig( | ||
onClick = { _, click -> | ||
println("${click.focus.x}, ${click.focus.y}") | ||
}, | ||
onViewChange = { viewPoint = this } | ||
), | ||
initialViewPoint = initialViewPoint, | ||
) | ||
|
||
SchemeView( | ||
mapState, | ||
features, | ||
) | ||
|
||
} | ||
|
||
|
||
fun main() { | ||
// renderComposable(rootElementId = "root") { | ||
CanvasBasedWindow("Maps demo", canvasElementId = "ComposeTarget") { | ||
App() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Compose App</title> | ||
<script type="application/javascript" src="skiko.js"></script> | ||
<script type="application/javascript" src="maps-wasm.js"></script> | ||
</head> | ||
<body> | ||
<canvas id="ComposeTarget"></canvas> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.