diff --git a/examples/README.md b/examples/README.md
index 0319f064b7..3d9d382898 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -4,9 +4,7 @@
| [Imageviewer](imageviewer) | Image Viewer application | Android, iOS, Desktop |
| [Codeviewer](codeviewer) | File browser and code viewer application | Android, iOS, Desktop |
| [Chat](chat) | A simple chat | Android, iOS, Desktop |
-| [Minesweeper](minesweeper) | A simple game where you need to find hidden mines | Android, iOS, Desktop |
-| [Falling Balls](falling-balls) | A simple game | Android, iOS, Desktop |
-| [Visual effects](visual-effects) | Visual effects | Android, iOS, Desktop |
+| [Graphics2D](graphics-2d) | 2D Games and graphics examples | Android, iOS, Desktop |
| [Widgets Gallery](widgets-gallery) | Gallery of standard widgets | Android, iOS, Desktop |
| [Todoapp Lite](todoapp-lite) | A simple todo app fully based on Compose | Android, iOS, Desktop |
| [Issues tracker](issues) | GitHub issue tracker with an adaptive UI and ktor-client | Android, Desktop |
diff --git a/examples/falling-balls/README.md b/examples/falling-balls/README.md
deleted file mode 100644
index 14804331d0..0000000000
--- a/examples/falling-balls/README.md
+++ /dev/null
@@ -1,21 +0,0 @@
-# Falling Balls game
-
-Game can run on Android, iOS, desktop or in a browser.
-
-## Setting up your development environment
-
-To setup the environment, please consult these [instructions](https://github.com/JetBrains/compose-multiplatform-template#setting-up-your-development-environment).
-
-## How to run
-
-Choose a run configuration for an appropriate target in Android Studio and run it.
-
-![run-configurations.png](run-configurations.png)
-
-## Run on desktop via Gradle
-
-`./gradlew desktopApp:run`
-
-## Run native on MacOS
-Choose **shared[macosX64]** or **shared[macosArm64]** configuration in IDE and run it.
-
diff --git a/examples/falling-balls/androidApp/src/androidMain/res/values/strings.xml b/examples/falling-balls/androidApp/src/androidMain/res/values/strings.xml
deleted file mode 100644
index 8475d8902c..0000000000
--- a/examples/falling-balls/androidApp/src/androidMain/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- Falling Balls
-
\ No newline at end of file
diff --git a/examples/falling-balls/desktopApp/src/jvmMain/kotlin/Main.kt b/examples/falling-balls/desktopApp/src/jvmMain/kotlin/Main.kt
deleted file mode 100644
index 0b1c80d006..0000000000
--- a/examples/falling-balls/desktopApp/src/jvmMain/kotlin/Main.kt
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-import androidx.compose.ui.ExperimentalComposeUiApi
-import androidx.compose.ui.unit.DpSize
-import androidx.compose.ui.unit.dp
-import androidx.compose.ui.window.WindowState
-import androidx.compose.ui.window.singleWindowApplication
-
-@OptIn(ExperimentalComposeUiApi::class)
-fun main() =
- singleWindowApplication(
- title = "Falling Balls",
- state = WindowState(size = DpSize(800.dp, 800.dp))
- ) {
- MainView()
- }
diff --git a/examples/falling-balls/iosApp/Configuration/Config.xcconfig b/examples/falling-balls/iosApp/Configuration/Config.xcconfig
deleted file mode 100644
index e6ec51dad2..0000000000
--- a/examples/falling-balls/iosApp/Configuration/Config.xcconfig
+++ /dev/null
@@ -1,3 +0,0 @@
-TEAM_ID=
-BUNDLE_ID=org.jetbrains.FallingBalls
-APP_NAME=FallingBalls
diff --git a/examples/falling-balls/jsApp/src/jsMain/kotlin/main.js.kt b/examples/falling-balls/jsApp/src/jsMain/kotlin/main.js.kt
deleted file mode 100644
index d646ee78b8..0000000000
--- a/examples/falling-balls/jsApp/src/jsMain/kotlin/main.js.kt
+++ /dev/null
@@ -1,15 +0,0 @@
- /*
- * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-import androidx.compose.ui.window.Window
-import org.jetbrains.skiko.wasm.onWasmReady
-
-fun main() {
- onWasmReady {
- Window("Falling Balls") {
- MainView()
- }
- }
-}
diff --git a/examples/falling-balls/jsApp/src/jsMain/resources/index.html b/examples/falling-balls/jsApp/src/jsMain/resources/index.html
deleted file mode 100644
index e68a4bccdb..0000000000
--- a/examples/falling-balls/jsApp/src/jsMain/resources/index.html
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
- compose multiplatform web demo
-
-
-
-
-
compose multiplatform web demo
-
-
-
-
-
-
diff --git a/examples/falling-balls/settings.gradle.kts b/examples/falling-balls/settings.gradle.kts
deleted file mode 100644
index 9f32e9dd8a..0000000000
--- a/examples/falling-balls/settings.gradle.kts
+++ /dev/null
@@ -1,32 +0,0 @@
-pluginManagement {
- repositories {
- gradlePluginPortal()
- maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
- google()
- }
-
- plugins {
- val kotlinVersion = extra["kotlin.version"] as String
- val agpVersion = extra["agp.version"] as String
- val composeVersion = extra["compose.version"] as String
-
- kotlin("jvm").version(kotlinVersion)
- kotlin("multiplatform").version(kotlinVersion)
- kotlin("android").version(kotlinVersion)
- id("com.android.base").version(agpVersion)
- id("com.android.application").version(agpVersion)
- id("com.android.library").version(agpVersion)
- id("org.jetbrains.compose").version(composeVersion)
- }
-}
-
-plugins {
- id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
-}
-
-rootProject.name = "falling-balls-mpp"
-
-include(":androidApp")
-include(":shared")
-include(":desktopApp")
-include(":jsApp")
diff --git a/examples/falling-balls/shared/build.gradle.kts b/examples/falling-balls/shared/build.gradle.kts
deleted file mode 100644
index b88d1299aa..0000000000
--- a/examples/falling-balls/shared/build.gradle.kts
+++ /dev/null
@@ -1,125 +0,0 @@
-@file:Suppress("OPT_IN_IS_NOT_ENABLED")
-
-import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
-
-
-plugins {
- kotlin("multiplatform")
- id("com.android.library")
- id("org.jetbrains.compose")
-}
-
-version = "1.0-SNAPSHOT"
-
-kotlin {
- androidTarget()
-
- jvm("desktop")
-
- js(IR) {
- browser()
- }
-
- macosX64 {
- binaries {
- executable {
- entryPoint = "main"
- }
- }
- }
- macosArm64 {
- binaries {
- executable {
- entryPoint = "main"
- }
- }
- }
-
- listOf(
- iosX64(),
- iosArm64(),
- iosSimulatorArm64()
- ).forEach { iosTarget ->
- iosTarget.binaries.framework {
- baseName = "shared"
- isStatic = true
- }
- }
-
- val enableKjsWorkaround = project.properties["workaround.kotlin.js.kt60852"] == "true"
-
- fun KotlinDependencyHandler.addCommonDependencies() {
- implementation(compose.ui)
- implementation(compose.runtime)
- implementation(compose.foundation)
- implementation(compose.material)
- @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
- implementation(compose.components.resources)
- }
-
- sourceSets {
- val commonMain by getting {
- dependencies {
- if (!enableKjsWorkaround) {
- addCommonDependencies()
- }
- }
- }
- val androidMain by getting {
- dependencies {
- api("androidx.activity:activity-compose:1.7.2")
- api("androidx.appcompat:appcompat:1.6.1")
- api("androidx.core:core-ktx:1.10.1")
- }
- }
- val iosMain by creating {
- dependsOn(commonMain)
- }
- val iosX64Main by getting {
- dependsOn(iosMain)
- }
- val iosArm64Main by getting {
- dependsOn(iosMain)
- }
- val iosSimulatorArm64Main by getting {
- dependsOn(iosMain)
- }
- val desktopMain by getting {
- dependencies {
- implementation(compose.desktop.common)
- }
- }
- val macosMain by creating {
- dependsOn(commonMain)
- }
- val macosArm64Main by getting {
- dependsOn(macosMain)
- }
- val jsMain by getting {
- dependencies {
- if (enableKjsWorkaround) {
- addCommonDependencies()
- }
- }
- }
- }
-}
-
-android {
- compileSdk = 34
- namespace = "org.jetbrains.fallingballs"
- sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
- sourceSets["main"].res.srcDirs("src/androidMain/res")
- sourceSets["main"].resources.srcDirs("src/commonMain/resources")
-
- defaultConfig {
- minSdk = 26
- }
- compileOptions {
- sourceCompatibility = JavaVersion.VERSION_17
- targetCompatibility = JavaVersion.VERSION_17
- }
- kotlin {
- jvmToolchain(17)
- }
-}
diff --git a/examples/falling-balls/shared/src/androidMain/kotlin/main.android.kt b/examples/falling-balls/shared/src/androidMain/kotlin/main.android.kt
deleted file mode 100644
index d638f6ee24..0000000000
--- a/examples/falling-balls/shared/src/androidMain/kotlin/main.android.kt
+++ /dev/null
@@ -1,12 +0,0 @@
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.remember
-
-object AndroidTime : Time {
- override fun now(): Long = System.nanoTime()
-}
-
-@Composable
-fun MainView() {
- val game = remember { Game(AndroidTime) }
- FallingBalls(game)
-}
\ No newline at end of file
diff --git a/examples/falling-balls/shared/src/desktopMain/kotlin/main.desktop.kt b/examples/falling-balls/shared/src/desktopMain/kotlin/main.desktop.kt
deleted file mode 100644
index 1c4b55ab06..0000000000
--- a/examples/falling-balls/shared/src/desktopMain/kotlin/main.desktop.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-import androidx.compose.desktop.ui.tooling.preview.Preview
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.remember
-
-object JvmTime : Time {
- override fun now(): Long = System.nanoTime()
-}
-
-@Composable
-fun MainView() {
- val game = remember { Game(JvmTime) }
- FallingBalls(game)
-}
-
-@Preview
-@Composable
-fun GamePreview() {
- MainView()
-}
\ No newline at end of file
diff --git a/examples/falling-balls/shared/src/iosMain/kotlin/main.ios.kt b/examples/falling-balls/shared/src/iosMain/kotlin/main.ios.kt
deleted file mode 100644
index 618bdd6d1d..0000000000
--- a/examples/falling-balls/shared/src/iosMain/kotlin/main.ios.kt
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-
-import androidx.compose.runtime.remember
-import androidx.compose.ui.window.ComposeUIViewController
-import platform.UIKit.UIViewController
-
-object IosTime : Time {
- override fun now(): Long = kotlin.system.getTimeNanos()
-}
-
-fun MainViewController() : UIViewController = ComposeUIViewController {
- val game = remember { Game(IosTime) }
- FallingBalls(game)
-}
-
diff --git a/examples/falling-balls/shared/src/jsMain/kotlin/main.js.kt b/examples/falling-balls/shared/src/jsMain/kotlin/main.js.kt
deleted file mode 100644
index 7e0e22e86a..0000000000
--- a/examples/falling-balls/shared/src/jsMain/kotlin/main.js.kt
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-import androidx.compose.foundation.layout.*
-import androidx.compose.material.RadioButton
-import androidx.compose.material.Text
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.MutableState
-import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.remember
-import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.sp
-import bouncingBalls.BouncingBallsApp
-
-object JsTime : Time {
- override fun now(): Long = kotlinx.browser.window.performance.now().toLong()
-}
-
-@Composable
-fun MainView() {
- val selectedExample = remember { mutableStateOf(Examples.FallingBalls) }
-
- Column(modifier = Modifier.fillMaxSize()) {
- ExamplesChooser(selectedExample)
- Spacer(modifier = Modifier.height(24.dp))
-
- when (selectedExample.value) {
- Examples.FallingBalls -> {
- val game = remember { Game(JsTime) }
- FallingBalls(game)
- }
- Examples.BouncingBalls -> {
- BouncingBallsApp(10)
- }
- }
- }
-}
-
-@Composable
-private fun ExamplesChooser(selected: MutableState) {
- Column {
- Row(verticalAlignment = Alignment.CenterVertically) {
- Text("Choose an example: ", fontSize = 16.sp)
-
- Examples.values().forEach {
- Row(verticalAlignment = Alignment.CenterVertically) {
- RadioButton(selected = selected.value == it, onClick = {
- selected.value = it
- })
- Text(it.name)
- }
- }
- }
- }
-}
-
-private enum class Examples {
- FallingBalls,
- BouncingBalls
-}
-
diff --git a/examples/falling-balls/shared/src/macosMain/kotlin/main.macos.kt b/examples/falling-balls/shared/src/macosMain/kotlin/main.macos.kt
deleted file mode 100644
index be803b013d..0000000000
--- a/examples/falling-balls/shared/src/macosMain/kotlin/main.macos.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-import androidx.compose.ui.window.Window
-import androidx.compose.runtime.remember
-import androidx.compose.ui.unit.dp
-import platform.AppKit.NSApp
-import platform.AppKit.NSApplication
-
-object MacosTime : Time {
- override fun now(): Long = kotlin.system.getTimeNanos()
-}
-
-fun main() {
- NSApplication.sharedApplication()
- Window("Falling Balls") {
- val game = remember { Game(MacosTime) }
- FallingBalls(game)
- }
- NSApp?.run()
-}
diff --git a/examples/falling-balls/.gitignore b/examples/graphics-2d/.gitignore
similarity index 100%
rename from examples/falling-balls/.gitignore
rename to examples/graphics-2d/.gitignore
diff --git a/examples/falling-balls/.run/desktopApp.run.xml b/examples/graphics-2d/.run/desktopApp.run.xml
similarity index 100%
rename from examples/falling-balls/.run/desktopApp.run.xml
rename to examples/graphics-2d/.run/desktopApp.run.xml
diff --git a/examples/graphics-2d/README.md b/examples/graphics-2d/README.md
new file mode 100644
index 0000000000..0cf145bd7b
--- /dev/null
+++ b/examples/graphics-2d/README.md
@@ -0,0 +1,24 @@
+# Graphics2D
+
+Example can run on Android, iOS, desktop or in a browser.
+
+## Setting up your development environment
+
+To setup the environment, please consult
+these [instructions](https://github.com/JetBrains/compose-multiplatform-template#setting-up-your-development-environment).
+
+## How to run
+
+Choose a run configuration for an appropriate target in Android Studio and run it.
+
+![run-configurations.png](run-configurations.png)
+
+## Run on desktop via Gradle
+
+`./gradlew desktopApp:run`
+
+## Run experimental native on MacOS
+
+`./gradlew runDebugExecutableMacosX64` (Works on Intel processors)
+`./gradlew runDebugExecutableMacosArm64` (Works on Arm processors)
+
diff --git a/examples/falling-balls/androidApp/build.gradle.kts b/examples/graphics-2d/androidApp/build.gradle.kts
similarity index 86%
rename from examples/falling-balls/androidApp/build.gradle.kts
rename to examples/graphics-2d/androidApp/build.gradle.kts
index 0d7ab8e11f..e09546327c 100644
--- a/examples/falling-balls/androidApp/build.gradle.kts
+++ b/examples/graphics-2d/androidApp/build.gradle.kts
@@ -17,9 +17,9 @@ kotlin {
android {
compileSdk = 34
- namespace = "org.jetbrains.fallingballs"
+ namespace = "org.jetbrains.graphics2d"
defaultConfig {
- applicationId = "org.jetbrains.FallingBalls"
+ applicationId = "org.jetbrains.Graphics2D"
minSdk = 26
targetSdk = 34
versionCode = 1
diff --git a/examples/falling-balls/androidApp/src/androidMain/AndroidManifest.xml b/examples/graphics-2d/androidApp/src/androidMain/AndroidManifest.xml
similarity index 100%
rename from examples/falling-balls/androidApp/src/androidMain/AndroidManifest.xml
rename to examples/graphics-2d/androidApp/src/androidMain/AndroidManifest.xml
diff --git a/examples/falling-balls/androidApp/src/androidMain/kotlin/org/jetbrains/fallingballs/MainActivity.kt b/examples/graphics-2d/androidApp/src/androidMain/kotlin/org/jetbrains/graphics2d/MainActivity.kt
similarity index 90%
rename from examples/falling-balls/androidApp/src/androidMain/kotlin/org/jetbrains/fallingballs/MainActivity.kt
rename to examples/graphics-2d/androidApp/src/androidMain/kotlin/org/jetbrains/graphics2d/MainActivity.kt
index ef41726dc2..2285f4485a 100644
--- a/examples/falling-balls/androidApp/src/androidMain/kotlin/org/jetbrains/fallingballs/MainActivity.kt
+++ b/examples/graphics-2d/androidApp/src/androidMain/kotlin/org/jetbrains/graphics2d/MainActivity.kt
@@ -1,4 +1,4 @@
-package org.jetbrains.fallingballs
+package org.jetbrains.graphics2d
import MainView
import android.os.Bundle
diff --git a/examples/graphics-2d/androidApp/src/androidMain/res/values/strings.xml b/examples/graphics-2d/androidApp/src/androidMain/res/values/strings.xml
new file mode 100644
index 0000000000..b459df13ca
--- /dev/null
+++ b/examples/graphics-2d/androidApp/src/androidMain/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ Graphics2D
+
\ No newline at end of file
diff --git a/examples/falling-balls/apple-id.png b/examples/graphics-2d/apple-id.png
similarity index 100%
rename from examples/falling-balls/apple-id.png
rename to examples/graphics-2d/apple-id.png
diff --git a/examples/falling-balls/build.gradle.kts b/examples/graphics-2d/build.gradle.kts
similarity index 100%
rename from examples/falling-balls/build.gradle.kts
rename to examples/graphics-2d/build.gradle.kts
diff --git a/examples/falling-balls/desktopApp/build.gradle.kts b/examples/graphics-2d/desktopApp/build.gradle.kts
similarity index 91%
rename from examples/falling-balls/desktopApp/build.gradle.kts
rename to examples/graphics-2d/desktopApp/build.gradle.kts
index 7606f45918..31d4aef6ca 100644
--- a/examples/falling-balls/desktopApp/build.gradle.kts
+++ b/examples/graphics-2d/desktopApp/build.gradle.kts
@@ -8,7 +8,7 @@ plugins {
kotlin {
jvm {}
sourceSets {
- val jvmMain by getting {
+ val jvmMain by getting {
dependencies {
implementation(compose.desktop.currentOs)
implementation(project(":shared"))
@@ -23,7 +23,7 @@ compose.desktop {
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
- packageName = "Falling Balls"
+ packageName = "Graphics2D"
packageVersion = "1.0.0"
windows {
diff --git a/examples/graphics-2d/desktopApp/src/jvmMain/kotlin/Main.kt b/examples/graphics-2d/desktopApp/src/jvmMain/kotlin/Main.kt
new file mode 100644
index 0000000000..72742a58ba
--- /dev/null
+++ b/examples/graphics-2d/desktopApp/src/jvmMain/kotlin/Main.kt
@@ -0,0 +1,30 @@
+import androidx.compose.ui.unit.DpSize
+import androidx.compose.ui.unit.coerceIn
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.window.Window
+import androidx.compose.ui.window.application
+import androidx.compose.ui.window.rememberWindowState
+
+
+private val INIT_SIZE = DpSize(800.dp, 800.dp)
+
+fun main() =
+ application {
+ val windowState = rememberWindowState(width = 800.dp, height = 800.dp)
+
+ Window(
+ onCloseRequest = ::exitApplication,
+ resizable = false,
+ title = "Graphics2D",
+ state = windowState,
+ ) {
+ Graphics2D(
+ requestWindowSize = { w, h ->
+ windowState.size = windowState.size.copy(
+ width = w.coerceIn(INIT_SIZE.width, Float.MAX_VALUE.dp),
+ height = h.coerceIn(INIT_SIZE.height, Float.MAX_VALUE.dp)
+ )
+ }
+ )
+ }
+ }
diff --git a/examples/falling-balls/gradle.properties b/examples/graphics-2d/gradle.properties
similarity index 100%
rename from examples/falling-balls/gradle.properties
rename to examples/graphics-2d/gradle.properties
diff --git a/examples/falling-balls/gradle/wrapper/gradle-wrapper.jar b/examples/graphics-2d/gradle/wrapper/gradle-wrapper.jar
similarity index 100%
rename from examples/falling-balls/gradle/wrapper/gradle-wrapper.jar
rename to examples/graphics-2d/gradle/wrapper/gradle-wrapper.jar
diff --git a/examples/falling-balls/gradle/wrapper/gradle-wrapper.properties b/examples/graphics-2d/gradle/wrapper/gradle-wrapper.properties
similarity index 100%
rename from examples/falling-balls/gradle/wrapper/gradle-wrapper.properties
rename to examples/graphics-2d/gradle/wrapper/gradle-wrapper.properties
diff --git a/examples/falling-balls/gradlew b/examples/graphics-2d/gradlew
similarity index 100%
rename from examples/falling-balls/gradlew
rename to examples/graphics-2d/gradlew
diff --git a/examples/falling-balls/gradlew.bat b/examples/graphics-2d/gradlew.bat
similarity index 100%
rename from examples/falling-balls/gradlew.bat
rename to examples/graphics-2d/gradlew.bat
diff --git a/examples/falling-balls/ios-app.png b/examples/graphics-2d/ios-app.png
similarity index 100%
rename from examples/falling-balls/ios-app.png
rename to examples/graphics-2d/ios-app.png
diff --git a/examples/graphics-2d/iosApp/Configuration/Config.xcconfig b/examples/graphics-2d/iosApp/Configuration/Config.xcconfig
new file mode 100644
index 0000000000..d5037986d0
--- /dev/null
+++ b/examples/graphics-2d/iosApp/Configuration/Config.xcconfig
@@ -0,0 +1,3 @@
+TEAM_ID=
+BUNDLE_ID=org.jetbrains.Graphics2D
+APP_NAME=Graphics2D
diff --git a/examples/falling-balls/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/graphics-2d/iosApp/iosApp.xcodeproj/project.pbxproj
similarity index 97%
rename from examples/falling-balls/iosApp/iosApp.xcodeproj/project.pbxproj
rename to examples/graphics-2d/iosApp/iosApp.xcodeproj/project.pbxproj
index bf37d47794..c810131d7a 100644
--- a/examples/falling-balls/iosApp/iosApp.xcodeproj/project.pbxproj
+++ b/examples/graphics-2d/iosApp/iosApp.xcodeproj/project.pbxproj
@@ -17,7 +17,7 @@
058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; };
2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; };
- 7555FF7B242A565900829871 /* FallingBalls.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FallingBalls.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 7555FF7B242A565900829871 /* Graphics2D.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Graphics2D.app; sourceTree = BUILT_PRODUCTS_DIR; };
7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; };
7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; };
@@ -54,7 +54,7 @@
7555FF7C242A565900829871 /* Products */ = {
isa = PBXGroup;
children = (
- 7555FF7B242A565900829871 /* FallingBalls.app */,
+ 7555FF7B242A565900829871 /* Graphics2D.app */,
);
name = Products;
sourceTree = "";
@@ -97,7 +97,7 @@
);
name = iosApp;
productName = iosApp;
- productReference = 7555FF7B242A565900829871 /* FallingBalls.app */;
+ productReference = 7555FF7B242A565900829871 /* Graphics2D.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
diff --git a/examples/falling-balls/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json b/examples/graphics-2d/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json
similarity index 100%
rename from examples/falling-balls/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json
rename to examples/graphics-2d/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json
diff --git a/examples/falling-balls/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/graphics-2d/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json
similarity index 100%
rename from examples/falling-balls/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json
rename to examples/graphics-2d/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json
diff --git a/examples/falling-balls/iosApp/iosApp/Assets.xcassets/Contents.json b/examples/graphics-2d/iosApp/iosApp/Assets.xcassets/Contents.json
similarity index 100%
rename from examples/falling-balls/iosApp/iosApp/Assets.xcassets/Contents.json
rename to examples/graphics-2d/iosApp/iosApp/Assets.xcassets/Contents.json
diff --git a/examples/falling-balls/iosApp/iosApp/ContentView.swift b/examples/graphics-2d/iosApp/iosApp/ContentView.swift
similarity index 83%
rename from examples/falling-balls/iosApp/iosApp/ContentView.swift
rename to examples/graphics-2d/iosApp/iosApp/ContentView.swift
index e9915e5fcf..56163e6393 100644
--- a/examples/falling-balls/iosApp/iosApp/ContentView.swift
+++ b/examples/graphics-2d/iosApp/iosApp/ContentView.swift
@@ -5,7 +5,7 @@ import shared
struct ContentView: View {
var body: some View {
ComposeView()
- .ignoresSafeArea(.keyboard) // Compose has own keyboard handler
+ .ignoresSafeArea(.all) // Compose has own keyboard handler
}
}
diff --git a/examples/falling-balls/iosApp/iosApp/Info.plist b/examples/graphics-2d/iosApp/iosApp/Info.plist
similarity index 100%
rename from examples/falling-balls/iosApp/iosApp/Info.plist
rename to examples/graphics-2d/iosApp/iosApp/Info.plist
diff --git a/examples/falling-balls/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json b/examples/graphics-2d/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json
similarity index 100%
rename from examples/falling-balls/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json
rename to examples/graphics-2d/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json
diff --git a/examples/falling-balls/iosApp/iosApp/iOSApp.swift b/examples/graphics-2d/iosApp/iosApp/iOSApp.swift
similarity index 100%
rename from examples/falling-balls/iosApp/iosApp/iOSApp.swift
rename to examples/graphics-2d/iosApp/iosApp/iOSApp.swift
diff --git a/examples/falling-balls/jsApp/build.gradle.kts b/examples/graphics-2d/jsApp/build.gradle.kts
similarity index 91%
rename from examples/falling-balls/jsApp/build.gradle.kts
rename to examples/graphics-2d/jsApp/build.gradle.kts
index 144006fa94..b6fc37668c 100644
--- a/examples/falling-balls/jsApp/build.gradle.kts
+++ b/examples/graphics-2d/jsApp/build.gradle.kts
@@ -9,7 +9,7 @@ kotlin {
binaries.executable()
}
sourceSets {
- val jsMain by getting {
+ val jsMain by getting {
dependencies {
implementation(project(":shared"))
implementation(compose.ui)
diff --git a/examples/graphics-2d/jsApp/src/jsMain/kotlin/main.js.kt b/examples/graphics-2d/jsApp/src/jsMain/kotlin/main.js.kt
new file mode 100644
index 0000000000..5c9cd84953
--- /dev/null
+++ b/examples/graphics-2d/jsApp/src/jsMain/kotlin/main.js.kt
@@ -0,0 +1,10 @@
+import androidx.compose.ui.window.Window
+import org.jetbrains.skiko.wasm.onWasmReady
+
+fun main() {
+ onWasmReady {
+ Window("Graphics2D") {
+ MainView()
+ }
+ }
+}
diff --git a/examples/minesweeper/jsApp/src/jsMain/resources/assets/clock.png b/examples/graphics-2d/jsApp/src/jsMain/resources/assets/clock.png
similarity index 100%
rename from examples/minesweeper/jsApp/src/jsMain/resources/assets/clock.png
rename to examples/graphics-2d/jsApp/src/jsMain/resources/assets/clock.png
diff --git a/examples/minesweeper/jsApp/src/jsMain/resources/assets/flag.png b/examples/graphics-2d/jsApp/src/jsMain/resources/assets/flag.png
similarity index 100%
rename from examples/minesweeper/jsApp/src/jsMain/resources/assets/flag.png
rename to examples/graphics-2d/jsApp/src/jsMain/resources/assets/flag.png
diff --git a/examples/minesweeper/jsApp/src/jsMain/resources/assets/mine.png b/examples/graphics-2d/jsApp/src/jsMain/resources/assets/mine.png
similarity index 100%
rename from examples/minesweeper/jsApp/src/jsMain/resources/assets/mine.png
rename to examples/graphics-2d/jsApp/src/jsMain/resources/assets/mine.png
diff --git a/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.xml b/examples/graphics-2d/jsApp/src/jsMain/resources/compose-community-primary.xml
similarity index 100%
rename from examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.xml
rename to examples/graphics-2d/jsApp/src/jsMain/resources/compose-community-primary.xml
diff --git a/examples/graphics-2d/jsApp/src/jsMain/resources/index.html b/examples/graphics-2d/jsApp/src/jsMain/resources/index.html
new file mode 100644
index 0000000000..c70f31b9a4
--- /dev/null
+++ b/examples/graphics-2d/jsApp/src/jsMain/resources/index.html
@@ -0,0 +1,16 @@
+
+
+
+
+ compose multiplatform web demo
+
+
+
+
+
compose multiplatform web demo
+
+
+
+
+
+
diff --git a/examples/falling-balls/jsApp/src/jsMain/resources/styles.css b/examples/graphics-2d/jsApp/src/jsMain/resources/styles.css
similarity index 100%
rename from examples/falling-balls/jsApp/src/jsMain/resources/styles.css
rename to examples/graphics-2d/jsApp/src/jsMain/resources/styles.css
diff --git a/examples/falling-balls/run-configurations.png b/examples/graphics-2d/run-configurations.png
similarity index 100%
rename from examples/falling-balls/run-configurations.png
rename to examples/graphics-2d/run-configurations.png
diff --git a/examples/minesweeper/settings.gradle.kts b/examples/graphics-2d/settings.gradle.kts
similarity index 96%
rename from examples/minesweeper/settings.gradle.kts
rename to examples/graphics-2d/settings.gradle.kts
index 6ed7a53ada..7e76f0ab40 100644
--- a/examples/minesweeper/settings.gradle.kts
+++ b/examples/graphics-2d/settings.gradle.kts
@@ -24,7 +24,7 @@ plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
}
-rootProject.name = "minesweeper"
+rootProject.name = "graphics-2d"
include(":androidApp")
include(":shared")
diff --git a/examples/minesweeper/shared/build.gradle.kts b/examples/graphics-2d/shared/build.gradle.kts
similarity index 94%
rename from examples/minesweeper/shared/build.gradle.kts
rename to examples/graphics-2d/shared/build.gradle.kts
index 0df0b481ae..adff5037ca 100644
--- a/examples/minesweeper/shared/build.gradle.kts
+++ b/examples/graphics-2d/shared/build.gradle.kts
@@ -15,7 +15,6 @@ kotlin {
androidTarget()
jvm("desktop")
-
js(IR) {
browser()
}
@@ -52,7 +51,7 @@ kotlin {
implementation(compose.ui)
implementation(compose.runtime)
implementation(compose.foundation)
- implementation(compose.material)
+ implementation(compose.material3)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
}
@@ -95,13 +94,9 @@ kotlin {
implementation(compose.desktop.common)
}
}
-
val macosMain by creating {
dependsOn(commonMain)
}
- val macosX64Main by getting {
- dependsOn(macosMain)
- }
val macosArm64Main by getting {
dependsOn(macosMain)
}
@@ -117,7 +112,7 @@ kotlin {
android {
compileSdk = 34
- namespace = "org.jetbrains.minesweeper"
+ namespace = "org.jetbrains.Graphics2D"
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
diff --git a/examples/falling-balls/shared/src/androidMain/AndroidManifest.xml b/examples/graphics-2d/shared/src/androidMain/AndroidManifest.xml
similarity index 100%
rename from examples/falling-balls/shared/src/androidMain/AndroidManifest.xml
rename to examples/graphics-2d/shared/src/androidMain/AndroidManifest.xml
diff --git a/examples/graphics-2d/shared/src/androidMain/kotlin/main.android.kt b/examples/graphics-2d/shared/src/androidMain/kotlin/main.android.kt
new file mode 100644
index 0000000000..ec2120b6db
--- /dev/null
+++ b/examples/graphics-2d/shared/src/androidMain/kotlin/main.android.kt
@@ -0,0 +1,6 @@
+import androidx.compose.runtime.Composable
+
+@Composable
+fun MainView() {
+ Graphics2D()
+}
diff --git a/examples/graphics-2d/shared/src/androidMain/kotlin/minesweeper/MineSweeper.android.kt b/examples/graphics-2d/shared/src/androidMain/kotlin/minesweeper/MineSweeper.android.kt
new file mode 100644
index 0000000000..181a5833e6
--- /dev/null
+++ b/examples/graphics-2d/shared/src/androidMain/kotlin/minesweeper/MineSweeper.android.kt
@@ -0,0 +1,3 @@
+package minesweeper
+
+actual fun hasRightClick() = false
diff --git a/examples/visual-effects/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt b/examples/graphics-2d/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt
similarity index 79%
rename from examples/visual-effects/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt
rename to examples/graphics-2d/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt
index 3dd3fe22d9..b9e71feb0d 100644
--- a/examples/visual-effects/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt
+++ b/examples/graphics-2d/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt
@@ -1,4 +1,4 @@
-package org.jetbrains.compose.demo.visuals.platform
+package visualeffects
import androidx.compose.ui.Modifier
diff --git a/examples/graphics-2d/shared/src/commonMain/kotlin/Graphics2D.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/Graphics2D.kt
new file mode 100644
index 0000000000..7554db7834
--- /dev/null
+++ b/examples/graphics-2d/shared/src/commonMain/kotlin/Graphics2D.kt
@@ -0,0 +1,110 @@
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.isSystemInDarkTheme
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.items
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.ArrowBack
+import androidx.compose.material3.Button
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.Icon
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Scaffold
+import androidx.compose.material3.Text
+import androidx.compose.material3.TopAppBar
+import androidx.compose.material3.darkColorScheme
+import androidx.compose.material3.lightColorScheme
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.MutableState
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.unit.Dp
+import androidx.compose.ui.unit.dp
+import bouncingballs.BouncingBallsApp
+import fallingballs.FallingBalls
+import minesweeper.MineSweeper
+import visualeffects.NYContent
+import visualeffects.RotatingWords
+import visualeffects.WaveEffectGrid
+
+private val TOP_APP_BAR_HEIGHT = 100.dp
+private val EMPTY_WINDOW_RESIZER: (width: Dp, height: Dp) -> Unit = { w, h -> }
+
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+fun Graphics2D(requestWindowSize: ((width: Dp, height: Dp) -> Unit) = EMPTY_WINDOW_RESIZER) {
+ val exampleState: MutableState = remember { mutableStateOf(null) }
+ val example = exampleState.value
+
+ MaterialTheme(
+ colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme()
+ ) {
+ Scaffold(
+ topBar = {
+ TopAppBar(
+ navigationIcon = {
+ if (example != null) {
+ Icon(
+ imageVector = Icons.Default.ArrowBack,
+ contentDescription = "Back",
+ modifier = Modifier.clickable {
+ exampleState.value = null
+ }
+ )
+ }
+ },
+ title = {
+ Text(example?.name ?: "Choose example")
+ }
+ )
+ }
+ ) {
+ Box(Modifier.padding(it)) {
+ if (example == null) {
+ LazyColumn(Modifier.padding(horizontal = 16.dp)) {
+ items(examples) {
+ Button(onClick = {
+ exampleState.value = it
+ }) {
+ Text(it.name)
+ }
+ }
+ }
+ } else {
+ example.content { w, h ->
+ requestWindowSize(w, h + TOP_APP_BAR_HEIGHT)
+ }
+ }
+ }
+
+ }
+ }
+}
+
+private class Example(
+ val name: String,
+ val content: @Composable (requestWindowSize: ((width: Dp, height: Dp) -> Unit)) -> Unit
+)
+
+private val examples: List = listOf(
+ Example("FallingBalls") {
+ FallingBalls()
+ },
+ Example("BouncingBalls") {
+ BouncingBallsApp()
+ },
+ Example("MineSweeper") {
+ MineSweeper(it)
+ },
+ Example("RotatingWords") {
+ RotatingWords()
+ },
+ Example("WaveEffectGrid") {
+ WaveEffectGrid()
+ },
+ Example("Happy New Year!") {
+ NYContent()
+ },
+)
diff --git a/examples/falling-balls/shared/src/commonMain/kotlin/bouncingBalls/BouncingBalls.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/bouncingballs/BouncingBalls.kt
similarity index 86%
rename from examples/falling-balls/shared/src/commonMain/kotlin/bouncingBalls/BouncingBalls.kt
rename to examples/graphics-2d/shared/src/commonMain/kotlin/bouncingballs/BouncingBalls.kt
index 58f5b65adb..09f813e468 100644
--- a/examples/falling-balls/shared/src/commonMain/kotlin/bouncingBalls/BouncingBalls.kt
+++ b/examples/graphics-2d/shared/src/commonMain/kotlin/bouncingballs/BouncingBalls.kt
@@ -1,28 +1,35 @@
-/*
- * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package bouncingBalls
+package bouncingballs
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.interaction.MutableInteractionSource
-import androidx.compose.foundation.layout.*
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.BoxWithConstraints
+import androidx.compose.foundation.layout.fillMaxHeight
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.offset
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
-import androidx.compose.runtime.*
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.MutableState
+import androidx.compose.runtime.key
+import androidx.compose.runtime.mutableStateListOf
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.withFrameNanos
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.pointerInput
-import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.unit.dp
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.max
+import kotlin.math.roundToInt
import kotlin.math.sin
import kotlin.random.Random
@@ -52,17 +59,16 @@ fun BouncingBallsApp(initialBallsCount: Int = 5) {
list
}
- Box(
+ BoxWithConstraints(
modifier = Modifier.fillMaxWidth()
.fillMaxHeight()
.border(width = 1.dp, color = Color.Black)
.noRippleClickable {
items += BouncingBall.createBouncingBall(offset = it)
- }.onSizeChanged {
- areaWidth = it.width
- areaHeight = it.height
}
) {
+ areaWidth = maxWidth.value.roundToInt()
+ areaHeight = maxHeight.value.roundToInt()
Balls(items)
}
diff --git a/examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/FallingBalls.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/FallingBalls.common.kt
similarity index 68%
rename from examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/FallingBalls.kt
rename to examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/FallingBalls.common.kt
index 731435037e..53814c8559 100644
--- a/examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/FallingBalls.kt
+++ b/examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/FallingBalls.common.kt
@@ -1,11 +1,20 @@
+package fallingballs
+
import androidx.compose.foundation.background
import androidx.compose.foundation.border
-import androidx.compose.foundation.layout.*
-import androidx.compose.material.Button
-import androidx.compose.material.Slider
-import androidx.compose.material.Text
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxHeight
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.width
+import androidx.compose.material3.Button
+import androidx.compose.material3.Slider
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.remember
import androidx.compose.runtime.withFrameNanos
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -15,7 +24,8 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
@Composable
-fun FallingBalls(game: Game) {
+fun FallingBalls() {
+ val game = remember { Game() }
val density = LocalDensity.current
Column {
Text(
@@ -23,7 +33,10 @@ fun FallingBalls(game: Game) {
fontSize = 20.sp,
color = Color(218, 120, 91)
)
- Text("Score: ${game.score} Time: ${game.elapsed / 1_000_000} Blocks: ${game.numBlocks.toInt()}", fontSize = 20.sp)
+ Text(
+ "Score: ${game.score} Time: ${game.elapsed / 1_000_000} Blocks: ${game.numBlocks.toInt()}",
+ fontSize = 20.sp
+ )
Row {
if (!game.started) {
Slider(
@@ -33,9 +46,6 @@ fun FallingBalls(game: Game) {
)
}
Button(
- modifier = Modifier
- .border(2.dp, Color(255, 215, 0))
- .background(Color.Yellow),
onClick = {
game.started = !game.started
if (game.started) {
@@ -45,18 +55,6 @@ fun FallingBalls(game: Game) {
) {
Text(if (game.started) "Stop" else "Start", fontSize = 25.sp)
}
- if (game.started) {
- Button(
- modifier = Modifier
- .offset(10.dp, 0.dp)
- .border(2.dp, Color(255, 215, 0))
- .background(Color.Yellow),
- onClick = {
- game.togglePause()
- }) {
- Text(if (game.paused) "Resume" else "Pause", fontSize = 25.sp)
- }
- }
}
if (game.started) {
Box(modifier = Modifier.height(20.dp))
@@ -76,12 +74,14 @@ fun FallingBalls(game: Game) {
LaunchedEffect(Unit) {
while (true) {
+ var previousTimeNanos = withFrameNanos { it }
withFrameNanos {
- if (game.started && !game.paused && !game.finished)
- game.update(it)
+ if (game.started && !game.paused && !game.finished) {
+ game.update((it - previousTimeNanos).coerceAtLeast(0))
+ previousTimeNanos = it
+ }
}
}
}
}
}
-
diff --git a/examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Game.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/Game.kt
similarity index 50%
rename from examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Game.kt
rename to examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/Game.kt
index b4bbe9d4a8..9480152ed2 100644
--- a/examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Game.kt
+++ b/examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/Game.kt
@@ -1,23 +1,18 @@
-/*
- * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-import androidx.compose.runtime.*
+package fallingballs
+
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateListOf
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.unit.*
+import androidx.compose.ui.unit.dp
import kotlin.random.Random
-interface Time {
- fun now(): Long
-}
-
-class Game(val time: Time) {
- private var previousTimeNanos: Long = Long.MAX_VALUE
+class Game() {
private val colors = arrayOf(
Color.Red, Color.Blue, Color.Cyan,
Color.Magenta, Color.Yellow, Color.Black
)
- private var startTime = 0L
var width by mutableStateOf(0.dp)
var height by mutableStateOf(0.dp)
@@ -36,30 +31,26 @@ class Game(val time: Time) {
var numBlocks by mutableStateOf(5f)
fun start() {
- previousTimeNanos = time.now()
- startTime = previousTimeNanos
clicked = 0
started = true
finished = false
paused = false
pieces.clear()
repeat(numBlocks.toInt()) { index ->
- pieces.add(PieceData(this, index * 1.5f + 5f, colors[index % colors.size]).also { piece ->
- piece.position = Random.nextDouble(0.0, 100.0).toFloat()
- })
+ pieces.add(
+ PieceData(
+ this,
+ index * 1.5f + 5f,
+ colors[index % colors.size]
+ ).also { piece ->
+ piece.position = Random.nextDouble(0.0, 100.0).toFloat()
+ })
}
}
- fun togglePause() {
- paused = !paused
- previousTimeNanos = time.now()
- }
-
- fun update(nanos: Long) {
- val dt = (nanos - previousTimeNanos).coerceAtLeast(0)
- previousTimeNanos = nanos
- elapsed = nanos - startTime
- pieces.forEach { it.update(dt) }
+ fun update(deltaTimeNanos: Long) {
+ elapsed += deltaTimeNanos
+ pieces.forEach { it.update(deltaTimeNanos) }
}
fun clicked(piece: PieceData) {
@@ -69,4 +60,4 @@ class Game(val time: Time) {
finished = true
}
}
-}
\ No newline at end of file
+}
diff --git a/examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Piece.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/Piece.kt
similarity index 89%
rename from examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Piece.kt
rename to examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/Piece.kt
index 14b96bfab0..118ca63df1 100644
--- a/examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Piece.kt
+++ b/examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/Piece.kt
@@ -1,7 +1,4 @@
-/*
- * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
+package fallingballs
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
@@ -53,4 +50,4 @@ data class PieceData(val game: Game, val velocity: Float, val color: Color) {
game.clicked(this)
}
}
-}
\ No newline at end of file
+}
diff --git a/examples/minesweeper/shared/src/commonMain/kotlin/BoardView.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/BoardView.kt
similarity index 95%
rename from examples/minesweeper/shared/src/commonMain/kotlin/BoardView.kt
rename to examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/BoardView.kt
index a72e93b88b..a31d098c94 100644
--- a/examples/minesweeper/shared/src/commonMain/kotlin/BoardView.kt
+++ b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/BoardView.kt
@@ -1,3 +1,5 @@
+package minesweeper
+
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
@@ -43,4 +45,4 @@ fun BoardView(game: GameController) = with(GameStyles) {
}
private fun GameStyles.getCellColor(cell: Cell): Color =
- if (cell.isOpened) openedCellColor else closedCellColor
\ No newline at end of file
+ if (cell.isOpened) openedCellColor else closedCellColor
diff --git a/examples/minesweeper/shared/src/commonMain/kotlin/GameController.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/GameController.kt
similarity index 97%
rename from examples/minesweeper/shared/src/commonMain/kotlin/GameController.kt
rename to examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/GameController.kt
index 154bdcfbbd..155ae15cdf 100644
--- a/examples/minesweeper/shared/src/commonMain/kotlin/GameController.kt
+++ b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/GameController.kt
@@ -1,36 +1,50 @@
+package minesweeper
+
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import kotlin.random.Random
-class GameController(private val options: GameSettings, private val onWin: (() -> Unit)? = null, private val onLose: (() -> Unit)? = null) {
+class GameController(
+ private val options: GameSettings,
+ private val onWin: (() -> Unit)? = null,
+ private val onLose: (() -> Unit)? = null
+) {
/** Number of rows in current board */
val rows: Int
get() = options.rows
+
/** Number of columns in current board */
val columns: Int
get() = options.columns
+
/** Number of bombs in current board */
val bombs: Int
get() = options.mines
+
/** True if current game has started, false if game is finished or until first cell is opened or flagged */
var running by mutableStateOf(false)
private set
+
/** True if game is ended (win or lose) */
var finished by mutableStateOf(false)
private set
+
/** Total number of flags set on cells, used for calculation of number of remaining bombs */
var flagsSet by mutableStateOf(0)
private set
+
/** Number of remaining cells */
var cellsToOpen by mutableStateOf(options.rows * options.columns - options.mines)
private set
+
/** Game timer, increments every second while game is running */
var seconds by mutableStateOf(0)
private set
/** Global monotonic time, updated with [onTimeTick] */
private var time = 0L
+
/** The time when user starts the game by opening or flagging any cell */
private var startTime = 0L
@@ -59,7 +73,7 @@ class GameController(private val options: GameSettings, private val onWin: (() -
mines: Collection>,
onWin: (() -> Unit)? = null,
onLose: (() -> Unit)? = null
- ) : this(GameSettings(rows, columns, mines.size), onWin, onLose) {
+ ) : this(GameSettings(rows, columns, mines.size), onWin, onLose) {
for (row in cells) {
for (cell in row) {
cell.hasBomb = false
@@ -290,4 +304,4 @@ class Cell(val row: Int, val column: Int) {
var isOpened by mutableStateOf(false)
var isFlagged by mutableStateOf(false)
var bombsNear = 0
-}
\ No newline at end of file
+}
diff --git a/examples/minesweeper/shared/src/commonMain/kotlin/gameInteraction.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/GameInteraction.kt
similarity index 98%
rename from examples/minesweeper/shared/src/commonMain/kotlin/gameInteraction.kt
rename to examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/GameInteraction.kt
index 77842f6123..a852418e1a 100644
--- a/examples/minesweeper/shared/src/commonMain/kotlin/gameInteraction.kt
+++ b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/GameInteraction.kt
@@ -1,3 +1,5 @@
+package minesweeper
+
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.combinedClickable
import androidx.compose.runtime.Composable
diff --git a/examples/minesweeper/shared/src/commonMain/kotlin/game.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/MineSweeper.common.kt
similarity index 89%
rename from examples/minesweeper/shared/src/commonMain/kotlin/game.kt
rename to examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/MineSweeper.common.kt
index 13c2d47b20..967c9db826 100644
--- a/examples/minesweeper/shared/src/commonMain/kotlin/game.kt
+++ b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/MineSweeper.common.kt
@@ -1,12 +1,14 @@
@file:Suppress("FunctionName")
-import androidx.compose.runtime.*
+package minesweeper
+
+
import androidx.compose.foundation.*
import androidx.compose.foundation.layout.*
-import androidx.compose.material.*
+import androidx.compose.material3.*
+import androidx.compose.runtime.*
import androidx.compose.ui.*
import androidx.compose.ui.graphics.Color
-
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.unit.*
import org.jetbrains.compose.resources.ExperimentalResourceApi
@@ -39,7 +41,7 @@ object GameStyles {
}
@Composable
-fun Game(requestWindowSize: ((width: Dp, height: Dp) -> Unit)? = null) = MainLayout {
+fun MineSweeper(requestWindowSize: ((width: Dp, height: Dp) -> Unit)? = null) = MainLayout {
var message by remember { mutableStateOf(null) }
val onWin = { message = "You win!" }
@@ -101,9 +103,10 @@ fun Game(requestWindowSize: ((width: Dp, height: Dp) -> Unit)? = null) = MainLay
}
// Cells
- Box(modifier = Modifier
- .border(GameStyles.boardBorderWidth, Color.White)
- .padding(GameStyles.boardPadding)
+ Box(
+ modifier = Modifier
+ .border(GameStyles.boardBorderWidth, Color.White)
+ .padding(GameStyles.boardPadding)
) {
BoardView(game)
}
@@ -119,6 +122,6 @@ fun Game(requestWindowSize: ((width: Dp, height: Dp) -> Unit)? = null) = MainLay
}
@Composable
-private fun MainLayout(block:@Composable ColumnScope.() -> Unit) {
+private fun MainLayout(block: @Composable ColumnScope.() -> Unit) {
Column { block() }
-}
\ No newline at end of file
+}
diff --git a/examples/minesweeper/shared/src/commonMain/kotlin/widgets.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/Widgets.kt
similarity index 97%
rename from examples/minesweeper/shared/src/commonMain/kotlin/widgets.kt
rename to examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/Widgets.kt
index 3a81aca773..6d00968141 100644
--- a/examples/minesweeper/shared/src/commonMain/kotlin/widgets.kt
+++ b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/Widgets.kt
@@ -1,11 +1,13 @@
@file:Suppress("FunctionName")
+package minesweeper
+
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
-import androidx.compose.material.Text
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -80,4 +82,4 @@ fun NewGameButton(text: String, onClick: () -> Unit) {
modifier = Modifier.padding(4.dp)
)
}
-}
\ No newline at end of file
+}
diff --git a/examples/visual-effects/shared/src/commonMain/kotlin/HappyNY.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/HappyNY.kt
similarity index 65%
rename from examples/visual-effects/shared/src/commonMain/kotlin/HappyNY.kt
rename to examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/HappyNY.kt
index b1df36b5ee..0a01191f6b 100644
--- a/examples/visual-effects/shared/src/commonMain/kotlin/HappyNY.kt
+++ b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/HappyNY.kt
@@ -1,25 +1,45 @@
-package org.jetbrains.compose.demo.visuals
+package visualeffects
import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.*
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.offset
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material.Surface
-import androidx.compose.material.Text
-import androidx.compose.runtime.*
+import androidx.compose.material3.Surface
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateListOf
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshots.SnapshotStateList
+import androidx.compose.runtime.withFrameNanos
import androidx.compose.ui.Alignment
-import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
-import androidx.compose.ui.draw.*
+import androidx.compose.ui.draw.alpha
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.draw.rotate
+import androidx.compose.ui.draw.scale
+import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.em
import androidx.compose.ui.unit.sp
-import org.jetbrains.compose.demo.visuals.platform.nanoTime
-import kotlin.math.*
+import kotlin.math.PI
+import kotlin.math.abs
+import kotlin.math.cos
+import kotlin.math.sin
import kotlin.random.Random
const val width = 1200
@@ -97,16 +117,16 @@ class DoubleRocket(val particle: Particle) {
state = STATE_SMALL_ROCKETS
}
- fun move(time: Long, prevTime: Long) {
+ fun move(timeElapsed: Long, deltaNanos: Long) {
if (rocket.state == rocket.STATE_ROCKET) {
- rocket.particle.move(time, prevTime)
- rocket.particle.gravity(time, prevTime)
+ rocket.particle.move(deltaNanos)
+ rocket.particle.gravity(deltaNanos)
} else {
rocket.rockets.forEach {
- it.move(time, prevTime)
+ it.move(timeElapsed, deltaNanos)
}
}
- rocket.checkState(time)
+ rocket.checkState(timeElapsed)
}
@Composable
@@ -126,8 +146,8 @@ class Rocket(val particle: Particle, val color: Color, val startTime: Long = 0)
var exploded = false
var parts: Array = emptyArray()
- fun checkExplode(time: Long) {
- if (time - startTime > 1200000000) {
+ fun checkExplode(timeElapsed: Long) {
+ if (timeElapsed - startTime > 1200000000) {
explode()
}
}
@@ -136,7 +156,14 @@ class Rocket(val particle: Particle, val color: Color, val startTime: Long = 0)
parts = Array(rocketPartsCount) {
val v = 0.5f + 1.5 * random()
val angle = 2 * PI * random()
- Particle(particle.x, particle.y, v * sin(angle) + particle.vx, v * cos(angle) + particle.vy, color, 1)
+ Particle(
+ particle.x,
+ particle.y,
+ v * sin(angle) + particle.vx,
+ v * cos(angle) + particle.vy,
+ color,
+ 1
+ )
}
exploded = true
}
@@ -149,15 +176,15 @@ class Rocket(val particle: Particle, val color: Color, val startTime: Long = 0)
return true
}
- fun move(time: Long, prevTime: Long) {
+ fun move(timeElapsed: Long, deltaNanos: Long) {
if (!exploded) {
- particle.move(time, prevTime)
- particle.gravity(time, prevTime)
- checkExplode(time)
+ particle.move(deltaNanos)
+ particle.gravity(deltaNanos)
+ checkExplode(timeElapsed)
} else {
parts.forEach {
- it.move(time, prevTime)
- it.gravity(time, prevTime)
+ it.move(deltaNanos)
+ it.gravity(deltaNanos)
}
}
}
@@ -174,20 +201,30 @@ class Rocket(val particle: Particle, val color: Color, val startTime: Long = 0)
}
}
-class Particle(var x: Double, var y: Double, var vx: Double, var vy: Double, val color: Color, val type: Int = 0) {
- fun move(time: Long, prevTime: Long) {
- x = (x + vx * (time - prevTime) / 30000000)
- y = (y + vy * (time - prevTime) / 30000000)
+class Particle(
+ var x: Double,
+ var y: Double,
+ var vx: Double,
+ var vy: Double,
+ val color: Color,
+ val type: Int = 0
+) {
+ fun move(deltaNanos: Long) {
+ x = (x + vx * deltaNanos / 30000000)
+ y = (y + vy * deltaNanos / 30000000)
}
- fun gravity(time: Long, prevTime: Long) {
- vy = vy + 1.0f * (time - prevTime) / 300000000
+ fun gravity(deltaNanos: Long) {
+ vy = vy + 1.0f * deltaNanos / 300000000
}
@Composable
fun draw() {
val alphaFactor = if (type == 0) 1.0f else 1 / (1 + abs(vy / 5)).toFloat()
- Box(Modifier.size(5.dp).offset(x.dp, y.dp).alpha(alphaFactor).clip(CircleShape).background(color))
+ Box(
+ Modifier.size(5.dp).offset(x.dp, y.dp).alpha(alphaFactor).clip(CircleShape)
+ .background(color)
+ )
for (i in 1..5) {
Box(
Modifier.size(4.dp).offset((x - vx / 2 * i).dp, (y - vy / 2 * i).dp)
@@ -199,7 +236,10 @@ class Particle(var x: Double, var y: Double, var vx: Double, var vy: Double, val
val rocket = DoubleRocket(Particle(0.0, 1000.0, 2.1, -12.5, Color.White))
-fun prepareStarsAndSnowFlakes(stars: SnapshotStateList, snowFlakes: SnapshotStateList) {
+fun prepareStarsAndSnowFlakes(
+ stars: SnapshotStateList,
+ snowFlakes: SnapshotStateList
+) {
for (i in 0..snowCount) {
snowFlakes.add(
SnowFlake(
@@ -214,7 +254,15 @@ fun prepareStarsAndSnowFlakes(stars: SnapshotStateList, snowFlakes: Snapsh
)
)
}
- val colors = arrayOf(Color.Red, Color.Yellow, Color.Green, Color.Yellow, Color.Cyan, Color.Magenta, Color.White)
+ val colors = arrayOf(
+ Color.Red,
+ Color.Yellow,
+ Color.Green,
+ Color.Yellow,
+ Color.Cyan,
+ Color.Magenta,
+ Color.White
+ )
for (i in 0..starCount) {
stars.add(
Star(
@@ -227,58 +275,58 @@ fun prepareStarsAndSnowFlakes(stars: SnapshotStateList, snowFlakes: Snapsh
}
}
-@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun NYContent() {
- var time by remember { mutableStateOf(nanoTime()) }
var started by remember { mutableStateOf(false) }
- var startTime = remember { nanoTime() }
- var prevTime by remember { mutableStateOf(nanoTime()) }
- val snowFlakes = remember { mutableStateListOf() }
val stars = remember { mutableStateListOf() }
var flickering2 by remember { mutableStateOf(true) }
+ val snowFlakes = remember { mutableStateListOf() }
remember { prepareStarsAndSnowFlakes(stars, snowFlakes) }
+ var timeElapsedNanos by remember { mutableStateOf(0L) }
Surface(
modifier = Modifier.fillMaxSize().padding(5.dp).shadow(3.dp, RoundedCornerShape(20.dp)),
color = Color.Black,
shape = RoundedCornerShape(20.dp)
) {
-
LaunchedEffect(Unit) {
while (true) {
+ var previousTimeNanos = withFrameNanos { it }
withFrameNanos {
- prevTime = time
- time = it
- }
- }
- }
-
- if (!started) { //animation starts with delay, so there is some time to start recording
- if (time - startTime in 7000000001..7099999999) println("ready!")
- if (time - startTime > 10000000000) {
- startTime = time //restarting timer
- started = true
- }
- }
+ val deltaTimeNanos = it - previousTimeNanos
+ timeElapsedNanos += deltaTimeNanos
+ previousTimeNanos = it
+
+ if (flickering2) {
+ if (timeElapsedNanos > 15500000000) { //note, that startTime has been updated above
+ flickering2 = false
+ }
+ }
+ if (started) {
+ rocket.move(timeElapsedNanos, deltaTimeNanos)
+ }
- if (flickering2) {
- if (time - startTime > 15500000000) { //note, that startTime has been updated above
- flickering2 = false
+ snowFlakes.forEach {
+ var y = it.y + ((it.v * deltaTimeNanos) / 30000000).dp
+ if (y > (height + 20).dp) {
+ y = -20.dp
+ }
+ it.y = y
+ }
+ }
}
}
- if (started) {
- rocket.move(time, prevTime)
- }
with(LocalDensity.current) {
Box(Modifier.fillMaxSize()) {
-
- snow(time, prevTime, snowFlakes, startTime)
-
+ snow(timeElapsedNanos, snowFlakes)
starrySky(stars)
- Row(modifier = Modifier.fillMaxSize(), verticalAlignment = Alignment.Bottom, horizontalArrangement = Arrangement.Center) {
+ Row(
+ modifier = Modifier.fillMaxSize(),
+ verticalAlignment = Alignment.Bottom,
+ horizontalArrangement = Arrangement.Center
+ ) {
Text(
fontSize = 10.em,
text = "202",
@@ -287,10 +335,10 @@ fun NYContent() {
color = Color.White
)
- val alpha = if (flickering2) flickeringAlpha(time) else 1.0f
+ val alpha = if (flickering2) flickeringAlpha(timeElapsedNanos) else 1.0f
Text(
fontSize = 10.em,
- text = "3",
+ text = "4",
modifier = Modifier.alpha(alpha).offset(0.dp, -15.dp),
color = Color.White
)
@@ -300,14 +348,15 @@ fun NYContent() {
//HNY
var i = 0
val angle = (HNYString.length / 2 * 5) * -1.0f
- val color = colorHNY(time, startTime)
+ val color = colorHNY(timeElapsedNanos)
HNYString.forEach {
- val alpha = alphaHNY(i, time, startTime)
+ val alpha = alphaHNY(i, timeElapsedNanos)
Text(
fontSize = 14.sp,
- text= it.toString(),
+ text = it.toString(),
color = color,
- modifier = Modifier.scale(5f).align(Alignment.Center).offset(0.dp, 85.dp)
+ modifier = Modifier.scale(5f).align(Alignment.Center)
+ .offset(0.dp, 85.dp)
.rotate((angle + 5.0f * i)).offset(0.dp, -90.dp).alpha(alpha)
)
i++
@@ -326,9 +375,9 @@ fun NYContent() {
}
}
-fun colorHNY(time: Long, startTime: Long): Color {
+fun colorHNY(timeElapsed: Long): Color {
val periodLength = 60
- val offset = ((time - startTime) / 80000000).toFloat() / periodLength
+ val offset = (timeElapsed.toFloat() / 80000000) / periodLength
val color1 = Color.Red
val color2 = Color.Yellow
val color3 = Color.Magenta
@@ -348,16 +397,16 @@ fun blend(color1: Color, color2: Color, fraction: Float): Color {
)
}
-fun alphaHNY(i: Int, time: Long, startTime: Long): Float {
- val period = period(time, startTime, 200) - i
+fun alphaHNY(i: Int, timeElapsed: Long): Float {
+ val period = period(timeElapsed, 200) - i
if (period < 0) return 0.0f
if (period > 10) return 1.0f
return 0.1f * period
}
-fun period(time: Long, startTime: Long, periodLength: Int, speed: Int = 1): Int {
+fun period(timeElapsed: Long, periodLength: Int, speed: Int = 1): Int {
val period = 200000000 / speed
- return (((time - startTime) / period) % periodLength).toInt()
+ return ((timeElapsed / period) % periodLength).toInt()
}
fun flickeringAlpha(time: Long): Float {
@@ -384,17 +433,15 @@ fun star(x: Dp, y: Dp, color: Color = Color.White, size: Dp) {
}
@Composable
-fun snow(time: Long, prevTime: Long, snowFlakes: SnapshotStateList, startTime: Long) {
- val deltaAngle = (time - startTime) / 100000000
+fun snow(timeElapsed: Long, snowFlakes: SnapshotStateList) {
+ val deltaAngle = timeElapsed.toFloat() / 100000000
with(LocalDensity.current) {
snowFlakes.forEach {
- var y = it.y + ((it.v * (time - prevTime)) / 300000000).dp
- if (y > (height + 20).dp) {
- y = -20.dp
- }
- it.y = y
- val x = it.x + (15 * sin(time.toDouble() / 3000000000 + it.phase)).dp
- snowFlake(Modifier.offset(x, y).scale(it.scale).rotate(it.angle + deltaAngle * it.rotate), it.alpha)
+ val x = it.x + (15 * sin(timeElapsed.toDouble() / 3000000000 + it.phase)).dp
+ snowFlake(
+ Modifier.offset(x, it.y).scale(it.scale).rotate(it.angle + deltaAngle * it.rotate),
+ it.alpha
+ )
}
}
}
@@ -416,7 +463,8 @@ fun snowFlake(modifier: Modifier, alpha: Float = 0.8f) {
fun snowFlakeInt(level: Int, angle: Float, shiftX: Dp, shiftY: Dp, alpha: Float) {
if (level > 3) return
Box(
- Modifier.offset(shiftX, shiftY).rotate(angle).width(100.dp).height(10.dp).scale(0.6f).alpha(1f)
+ Modifier.offset(shiftX, shiftY).rotate(angle).width(100.dp).height(10.dp).scale(0.6f)
+ .alpha(1f)
.background(Color.White.copy(alpha = alpha))
) {
snowFlakeInt(level + 1, 30f, 12.dp, 20.dp, alpha * 0.8f)
diff --git a/examples/visual-effects/shared/src/commonMain/kotlin/platform/PointerEventKind.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/PointerEvent.common.kt
similarity index 77%
rename from examples/visual-effects/shared/src/commonMain/kotlin/platform/PointerEventKind.kt
rename to examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/PointerEvent.common.kt
index 88fb8f8025..696cd60117 100644
--- a/examples/visual-effects/shared/src/commonMain/kotlin/platform/PointerEventKind.kt
+++ b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/PointerEvent.common.kt
@@ -1,4 +1,4 @@
-package org.jetbrains.compose.demo.visuals.platform
+package visualeffects
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.forEachGesture
@@ -6,6 +6,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.input.pointer.PointerEvent
import androidx.compose.ui.input.pointer.pointerInput
+
enum class PointerEventKind {
Move,
In,
@@ -14,7 +15,10 @@ enum class PointerEventKind {
class Position(val x: Int, val y: Int)
-expect fun Modifier.onPointerEvent(eventKind: PointerEventKind, onEvent: Position.() -> Unit): Modifier
+expect fun Modifier.onPointerEvent(
+ eventKind: PointerEventKind,
+ onEvent: Position.() -> Unit
+): Modifier
fun Modifier.onPointerEventMobileImpl(
eventKind: PointerEventKind,
@@ -37,7 +41,10 @@ fun Modifier.onPointerEventMobileImpl(
val event: PointerEvent = awaitPointerEvent()
if (eventKind == PointerEventKind.Move) {
- Position(event.changes.first().position.x.toInt(), event.changes.first().position.y.toInt()).onEvent()
+ Position(
+ event.changes.first().position.x.toInt(),
+ event.changes.first().position.y.toInt()
+ ).onEvent()
}
} while (event.changes.any { it.pressed })
@@ -49,4 +56,3 @@ fun Modifier.onPointerEventMobileImpl(
}
}
}
-
diff --git a/examples/visual-effects/shared/src/commonMain/kotlin/RotatingWords.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/RotatingWords.kt
similarity index 88%
rename from examples/visual-effects/shared/src/commonMain/kotlin/RotatingWords.kt
rename to examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/RotatingWords.kt
index 34070537f4..16f04f3b3e 100644
--- a/examples/visual-effects/shared/src/commonMain/kotlin/RotatingWords.kt
+++ b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/RotatingWords.kt
@@ -1,11 +1,11 @@
-package org.jetbrains.compose.demo.visuals
+package visualeffects
import androidx.compose.animation.core.*
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
-import androidx.compose.material.Text
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
@@ -62,19 +62,27 @@ fun Words() {
val color3 = Color(0xFD, 0xB6, 0x0D)
val color4 = Color(0xFC, 0xF8, 0x4A)
- Column(modifier = Modifier
- .fillMaxSize()
- .padding(16.dp)
+ Column(
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(16.dp)
) {
Word(position = baseRu, angle = angle, scale = scale, text = "Ваш", color = color1)
Word(position = baseEn, angle = angle, scale = scale, text = "Your", color = color2)
Word(position = baseCh, angle = angle, scale = scale, text = "您的", color = color3)
Word(position = baseJa, angle = angle, scale = scale, text = "あなたの", color = color4)
- Word(position = baseText, angle = 0f, scale = 6f, text = " Compose\nMultiplatform", color = Color(52, 67, 235),
- alpha = 0.4f)
+ Word(
+ position = baseText,
+ angle = 0f,
+ scale = 6f,
+ text = " Compose\nMultiplatform",
+ color = Color(52, 67, 235),
+ alpha = 0.4f
+ )
val size = 80.dp * scale
- Image(logoImg, contentDescription = "Logo",
+ Image(
+ logoImg, contentDescription = "Logo",
modifier = Modifier
.offset(baseLogo.x - size / 2, baseLogo.y - size / 2)
.size(size)
@@ -84,8 +92,10 @@ fun Words() {
}
@Composable
-fun Word(position: DpOffset, angle: Float, scale: Float, text: String,
- color: Color, alpha: Float = 0.8f) {
+fun Word(
+ position: DpOffset, angle: Float, scale: Float, text: String,
+ color: Color, alpha: Float = 0.8f
+) {
Text(
modifier = Modifier
.offset(position.x, position.y)
diff --git a/examples/visual-effects/shared/src/commonMain/kotlin/WaveEffect.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/WaveEffect.kt
similarity index 83%
rename from examples/visual-effects/shared/src/commonMain/kotlin/WaveEffect.kt
rename to examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/WaveEffect.kt
index 71a41bb2d8..a3ca49a495 100644
--- a/examples/visual-effects/shared/src/commonMain/kotlin/WaveEffect.kt
+++ b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/WaveEffect.kt
@@ -1,9 +1,9 @@
-package org.jetbrains.compose.demo.visuals
+package visualeffects
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material.*
+import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
@@ -11,9 +11,6 @@ import androidx.compose.ui.draw.*
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
-import org.jetbrains.compose.demo.visuals.platform.PointerEventKind
-import org.jetbrains.compose.demo.visuals.platform.nanoTime
-import org.jetbrains.compose.demo.visuals.platform.onPointerEvent
import kotlin.math.*
@OptIn(ExperimentalComposeUiApi::class)
@@ -25,23 +22,31 @@ fun WaveEffectGrid() {
var centerY by remember { mutableStateOf(900) }
var vX by remember { mutableStateOf(0) }
var vY by remember { mutableStateOf(0) }
+ var timeElapsedNanos by remember { mutableStateOf(0L) }
+
+ LaunchedEffect(Unit) {
+ while (true) {
+ var previousTimeNanos = withFrameNanos { it }
+ withFrameNanos {
+ val deltaTimeNanos = it - previousTimeNanos
+ timeElapsedNanos += deltaTimeNanos
+ previousTimeNanos = it
+
+ if (State.entered) {
+ centerX = (centerX + vX * deltaTimeNanos / 1000000000).toInt()
+ if (centerX < -100) centerX = -100
+ if (centerX > 2600) centerX = 2600
+ vX =
+ (vX * (1 - deltaTimeNanos.toDouble() / 500000000) + 10 * (mouseX - centerX) * deltaTimeNanos / 1000000000).toInt()
+ centerY = (centerY + vY * deltaTimeNanos / 1000000000).toInt()
+ if (centerY < -100) centerY = -100
+ if (centerY > 1800) centerY = 1800
+ vY =
+ (vY * (1 - deltaTimeNanos.toDouble() / 500000000) + 5 * (mouseY - centerY) * deltaTimeNanos / 1000000000).toInt()
- var time by remember { mutableStateOf(nanoTime()) }
- var prevTime by remember { mutableStateOf(nanoTime()) }
-
- if (State.entered) {
- centerX = (centerX + vX * (time - prevTime) / 1000000000).toInt()
- if (centerX < -100) centerX = -100
- if (centerX > 2600) centerX = 2600
- vX =
- (vX * (1 - (time - prevTime).toDouble() / 500000000) + 10 * (mouseX - centerX) * (time - prevTime) / 1000000000).toInt()
- centerY = (centerY + vY * (time - prevTime) / 1000000000).toInt()
- if (centerY < -100) centerY = -100
- if (centerY > 1800) centerY = 1800
- vY =
- (vY * (1 - (time - prevTime).toDouble() / 500000000) + 5 * (mouseY - centerY) * (time - prevTime) / 1000000000).toInt()
-
- prevTime = time
+ }
+ }
+ }
}
Surface(
@@ -71,8 +76,8 @@ fun WaveEffectGrid() {
x = if (evenRow) 10 + shift else 10
while (x < 1190) {
val size: Int = size(x, y, pointerOffsetX, pointerOffsety)
- val color = boxColor(x, y, time, pointerOffsetX, pointerOffsety)
- Dot(size, Modifier.offset(x.dp, y.dp), color, time)
+ val color = boxColor(x, y, timeElapsedNanos, pointerOffsetX, pointerOffsety)
+ Dot(size, Modifier.offset(x.dp, y.dp), color, timeElapsedNanos)
x += shift * 2
}
y += shift
@@ -81,14 +86,6 @@ fun WaveEffectGrid() {
HighPanel(pointerOffsetX, pointerOffsety)
}
- LaunchedEffect(Unit) {
- while (true) {
- withFrameNanos {
- time = it
- }
- }
- }
-
}
}
diff --git a/examples/minesweeper/shared/src/commonMain/resources/assets/clock.png b/examples/graphics-2d/shared/src/commonMain/resources/assets/clock.png
similarity index 100%
rename from examples/minesweeper/shared/src/commonMain/resources/assets/clock.png
rename to examples/graphics-2d/shared/src/commonMain/resources/assets/clock.png
diff --git a/examples/minesweeper/shared/src/commonMain/resources/assets/flag.png b/examples/graphics-2d/shared/src/commonMain/resources/assets/flag.png
similarity index 100%
rename from examples/minesweeper/shared/src/commonMain/resources/assets/flag.png
rename to examples/graphics-2d/shared/src/commonMain/resources/assets/flag.png
diff --git a/examples/minesweeper/shared/src/commonMain/resources/assets/mine.png b/examples/graphics-2d/shared/src/commonMain/resources/assets/mine.png
similarity index 100%
rename from examples/minesweeper/shared/src/commonMain/resources/assets/mine.png
rename to examples/graphics-2d/shared/src/commonMain/resources/assets/mine.png
diff --git a/examples/graphics-2d/shared/src/commonMain/resources/compose-community-primary.xml b/examples/graphics-2d/shared/src/commonMain/resources/compose-community-primary.xml
new file mode 100644
index 0000000000..d7bf7955f4
--- /dev/null
+++ b/examples/graphics-2d/shared/src/commonMain/resources/compose-community-primary.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
diff --git a/examples/minesweeper/shared/src/commonTest/kotlin/GameControllerTest.kt b/examples/graphics-2d/shared/src/commonTest/kotlin/minesweeper/GameControllerTest.kt
similarity index 99%
rename from examples/minesweeper/shared/src/commonTest/kotlin/GameControllerTest.kt
rename to examples/graphics-2d/shared/src/commonTest/kotlin/minesweeper/GameControllerTest.kt
index e18ac5a1f9..887b30fbb4 100644
--- a/examples/minesweeper/shared/src/commonTest/kotlin/GameControllerTest.kt
+++ b/examples/graphics-2d/shared/src/commonTest/kotlin/minesweeper/GameControllerTest.kt
@@ -1,3 +1,5 @@
+package minesweeper
+
import kotlin.test.*
class GameControllerTest {
diff --git a/examples/graphics-2d/shared/src/desktopMain/kotlin/minesweeper/MineSweeper.desktop.kt b/examples/graphics-2d/shared/src/desktopMain/kotlin/minesweeper/MineSweeper.desktop.kt
new file mode 100644
index 0000000000..303963a3f0
--- /dev/null
+++ b/examples/graphics-2d/shared/src/desktopMain/kotlin/minesweeper/MineSweeper.desktop.kt
@@ -0,0 +1,3 @@
+package minesweeper
+
+actual fun hasRightClick() = true
diff --git a/examples/visual-effects/shared/src/desktopMain/kotlin/platform/PointerEventKind.desktop.kt b/examples/graphics-2d/shared/src/desktopMain/kotlin/visualeffects/PointerEvent.desktop.kt
similarity index 93%
rename from examples/visual-effects/shared/src/desktopMain/kotlin/platform/PointerEventKind.desktop.kt
rename to examples/graphics-2d/shared/src/desktopMain/kotlin/visualeffects/PointerEvent.desktop.kt
index cc933fc2bb..c33d60853c 100644
--- a/examples/visual-effects/shared/src/desktopMain/kotlin/platform/PointerEventKind.desktop.kt
+++ b/examples/graphics-2d/shared/src/desktopMain/kotlin/visualeffects/PointerEvent.desktop.kt
@@ -1,4 +1,4 @@
-package org.jetbrains.compose.demo.visuals.platform
+package visualeffects
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
@@ -20,4 +20,4 @@ actual fun Modifier.onPointerEvent(
return this.onPointerEvent(eventType) {
Position(it.changes.first().position.x.toInt(), it.changes.first().position.y.toInt()).onEvent()
}
-}
\ No newline at end of file
+}
diff --git a/examples/graphics-2d/shared/src/iosMain/kotlin/main.ios.kt b/examples/graphics-2d/shared/src/iosMain/kotlin/main.ios.kt
new file mode 100644
index 0000000000..c075a8db12
--- /dev/null
+++ b/examples/graphics-2d/shared/src/iosMain/kotlin/main.ios.kt
@@ -0,0 +1,6 @@
+import androidx.compose.ui.window.ComposeUIViewController
+import platform.UIKit.UIViewController
+
+fun MainViewController(): UIViewController = ComposeUIViewController {
+ Graphics2D()
+}
diff --git a/examples/graphics-2d/shared/src/iosMain/kotlin/minesweeper/MineSweeper.ios.kt b/examples/graphics-2d/shared/src/iosMain/kotlin/minesweeper/MineSweeper.ios.kt
new file mode 100644
index 0000000000..181a5833e6
--- /dev/null
+++ b/examples/graphics-2d/shared/src/iosMain/kotlin/minesweeper/MineSweeper.ios.kt
@@ -0,0 +1,3 @@
+package minesweeper
+
+actual fun hasRightClick() = false
diff --git a/examples/visual-effects/shared/src/iosMain/kotlin/platform/PointerEventKind.ios.kt b/examples/graphics-2d/shared/src/iosMain/kotlin/visualeffects/PointerEvent.ios.kt
similarity index 79%
rename from examples/visual-effects/shared/src/iosMain/kotlin/platform/PointerEventKind.ios.kt
rename to examples/graphics-2d/shared/src/iosMain/kotlin/visualeffects/PointerEvent.ios.kt
index 3dd3fe22d9..b9e71feb0d 100644
--- a/examples/visual-effects/shared/src/iosMain/kotlin/platform/PointerEventKind.ios.kt
+++ b/examples/graphics-2d/shared/src/iosMain/kotlin/visualeffects/PointerEvent.ios.kt
@@ -1,4 +1,4 @@
-package org.jetbrains.compose.demo.visuals.platform
+package visualeffects
import androidx.compose.ui.Modifier
diff --git a/examples/graphics-2d/shared/src/jsMain/kotlin/main.js.kt b/examples/graphics-2d/shared/src/jsMain/kotlin/main.js.kt
new file mode 100644
index 0000000000..ec2120b6db
--- /dev/null
+++ b/examples/graphics-2d/shared/src/jsMain/kotlin/main.js.kt
@@ -0,0 +1,6 @@
+import androidx.compose.runtime.Composable
+
+@Composable
+fun MainView() {
+ Graphics2D()
+}
diff --git a/examples/graphics-2d/shared/src/jsMain/kotlin/minesweeper/MineSweeepr.js.kt b/examples/graphics-2d/shared/src/jsMain/kotlin/minesweeper/MineSweeepr.js.kt
new file mode 100644
index 0000000000..181a5833e6
--- /dev/null
+++ b/examples/graphics-2d/shared/src/jsMain/kotlin/minesweeper/MineSweeepr.js.kt
@@ -0,0 +1,3 @@
+package minesweeper
+
+actual fun hasRightClick() = false
diff --git a/examples/graphics-2d/shared/src/jsMain/kotlin/visualeffects/PointerEvent.js.kt b/examples/graphics-2d/shared/src/jsMain/kotlin/visualeffects/PointerEvent.js.kt
new file mode 100644
index 0000000000..83f87cbc24
--- /dev/null
+++ b/examples/graphics-2d/shared/src/jsMain/kotlin/visualeffects/PointerEvent.js.kt
@@ -0,0 +1,26 @@
+package visualeffects
+
+import androidx.compose.ui.ExperimentalComposeUiApi
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.input.pointer.PointerEventType
+import androidx.compose.ui.input.pointer.onPointerEvent
+
+@OptIn(ExperimentalComposeUiApi::class)
+actual fun Modifier.onPointerEvent(
+ eventKind: PointerEventKind,
+ onEvent: Position.() -> Unit
+): Modifier {
+
+ val eventType: PointerEventType = when (eventKind) {
+ PointerEventKind.Move -> PointerEventType.Move
+ PointerEventKind.In -> PointerEventType.Enter
+ PointerEventKind.Out -> PointerEventType.Exit
+ }
+
+ return this.onPointerEvent(eventType) {
+ Position(
+ it.changes.first().position.x.toInt(),
+ it.changes.first().position.y.toInt()
+ ).onEvent()
+ }
+}
diff --git a/examples/graphics-2d/shared/src/macosMain/kotlin/main.macos.kt b/examples/graphics-2d/shared/src/macosMain/kotlin/main.macos.kt
new file mode 100644
index 0000000000..d450440347
--- /dev/null
+++ b/examples/graphics-2d/shared/src/macosMain/kotlin/main.macos.kt
@@ -0,0 +1,11 @@
+import androidx.compose.ui.window.Window
+import platform.AppKit.NSApp
+import platform.AppKit.NSApplication
+
+fun main() {
+ NSApplication.sharedApplication()
+ Window("Graphics2D") {
+ Graphics2D()
+ }
+ NSApp?.run()
+}
diff --git a/examples/graphics-2d/shared/src/macosMain/kotlin/minesweeper/MineSweeper.macos.kt b/examples/graphics-2d/shared/src/macosMain/kotlin/minesweeper/MineSweeper.macos.kt
new file mode 100644
index 0000000000..181a5833e6
--- /dev/null
+++ b/examples/graphics-2d/shared/src/macosMain/kotlin/minesweeper/MineSweeper.macos.kt
@@ -0,0 +1,3 @@
+package minesweeper
+
+actual fun hasRightClick() = false
diff --git a/examples/graphics-2d/shared/src/macosMain/kotlin/visualeffects/PointerEventKind.macos.kt b/examples/graphics-2d/shared/src/macosMain/kotlin/visualeffects/PointerEventKind.macos.kt
new file mode 100644
index 0000000000..7ceb8d6bfe
--- /dev/null
+++ b/examples/graphics-2d/shared/src/macosMain/kotlin/visualeffects/PointerEventKind.macos.kt
@@ -0,0 +1,27 @@
+package visualeffects
+
+import androidx.compose.ui.ExperimentalComposeUiApi
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.input.pointer.PointerEventType
+import androidx.compose.ui.input.pointer.onPointerEvent
+
+
+@OptIn(ExperimentalComposeUiApi::class)
+actual fun Modifier.onPointerEvent(
+ eventKind: PointerEventKind,
+ onEvent: Position.() -> Unit
+): Modifier {
+
+ val eventType: PointerEventType = when (eventKind) {
+ PointerEventKind.Move -> PointerEventType.Move
+ PointerEventKind.In -> PointerEventType.Enter
+ PointerEventKind.Out -> PointerEventType.Exit
+ }
+
+ return this.onPointerEvent(eventType) {
+ Position(
+ it.changes.first().position.x.toInt(),
+ it.changes.first().position.y.toInt()
+ ).onEvent()
+ }
+}
diff --git a/examples/minesweeper/.gitignore b/examples/minesweeper/.gitignore
deleted file mode 100644
index fedf972a67..0000000000
--- a/examples/minesweeper/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-local.properties
-iosApp/Podfile.lock
-iosApp/Pods/*
-iosApp/iosApp.xcworkspace/*
-iosApp/iosApp.xcodeproj/*
-!iosApp/iosApp.xcodeproj/project.pbxproj
-shared/shared.podspec
diff --git a/examples/minesweeper/.run/desktopApp.run.xml b/examples/minesweeper/.run/desktopApp.run.xml
deleted file mode 100644
index 7af7e15f4b..0000000000
--- a/examples/minesweeper/.run/desktopApp.run.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
- true
- true
- false
-
-
-
\ No newline at end of file
diff --git a/examples/minesweeper/README.md b/examples/minesweeper/README.md
deleted file mode 100644
index 68d98e4f57..0000000000
--- a/examples/minesweeper/README.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# Minesweeper
-
-A simple game powered by Compose Multiplatform.
-
-Game can run on Android, iOS, desktop or in a browser.
-
-## Setting up your development environment
-
-To setup the environment, please consult these [instructions](https://github.com/JetBrains/compose-multiplatform-template#setting-up-your-development-environment).
-
-## How to run
-
-Choose a run configuration for an appropriate target in Android Studio and run it.
-
-![run-configurations.png](run-configurations.png)
-
-## Run on desktop via Gradle
-
-`./gradlew desktopApp:run`
-
-## Run native on MacOS
-`./gradlew runDebugExecutableMacosX64` (Works on Intel processors)
-
-## Credits
-