diff --git a/sample/length/.gitignore b/sample/length/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/sample/length/.gitignore @@ -0,0 +1 @@ +/build diff --git a/sample/length/build.gradle.kts b/sample/length/build.gradle.kts new file mode 100644 index 0000000..0b25337 --- /dev/null +++ b/sample/length/build.gradle.kts @@ -0,0 +1,8 @@ +import com.soywiz.korge.gradle.* + +apply() + +korge { + id = "com.soywiz.samples.length" + targetDefault() +} diff --git a/sample/length/src/commonMain/kotlin/main.kt b/sample/length/src/commonMain/kotlin/main.kt new file mode 100644 index 0000000..c0d677e --- /dev/null +++ b/sample/length/src/commonMain/kotlin/main.kt @@ -0,0 +1,23 @@ +import com.soywiz.korge.* +import com.soywiz.korge.component.length.* +import com.soywiz.korge.view.* +import com.soywiz.korim.color.* +import com.soywiz.korma.geom.* + +suspend fun main() { + Korge(width = 512, height = 512, bgcolor = Colors["#2b2b2b"], clipBorders = false, scaleAnchor = Anchor.TOP_LEFT) { + //Korge(width = 512, height = 512, bgcolor = Colors["#2b2b2b"], clipBorders = false, scaleAnchor = Anchor.TOP_LEFT, scaleMode = ScaleMode.NO_SCALE) { + //Korge(width = 512, height = 512, bgcolor = Colors["#2b2b2b"]) { + solidRect(512, 512, Colors.DARKOLIVEGREEN).lengths { + //width = 100.vw + //height = 100.vh + } + solidRect(0, 0, Colors.RED).centered.lengths { + x = 50.vw + y = 50.vh + //y = 50.vh - (3.cm / 2) + width = 50.vw + height = 3.cm + } + } +} diff --git a/sample/length/src/commonMain/resources/9patch.9.png b/sample/length/src/commonMain/resources/9patch.9.png new file mode 100644 index 0000000..063c03e Binary files /dev/null and b/sample/length/src/commonMain/resources/9patch.9.png differ diff --git a/sample/length/src/commonMain/resources/korge.atlas b/sample/length/src/commonMain/resources/korge.atlas new file mode 100644 index 0000000..d1a2e64 --- /dev/null +++ b/sample/length/src/commonMain/resources/korge.atlas @@ -0,0 +1 @@ +korge \ No newline at end of file diff --git a/sample/length/src/commonMain/resources/korge.png b/sample/length/src/commonMain/resources/korge.png new file mode 100644 index 0000000..0526e1d Binary files /dev/null and b/sample/length/src/commonMain/resources/korge.png differ diff --git a/sample/length/src/commonMain/resources/korge/9patch.9.png b/sample/length/src/commonMain/resources/korge/9patch.9.png new file mode 100644 index 0000000..063c03e Binary files /dev/null and b/sample/length/src/commonMain/resources/korge/9patch.9.png differ diff --git a/sample/length/src/commonMain/resources/korge/korge.png b/sample/length/src/commonMain/resources/korge/korge.png new file mode 100644 index 0000000..0526e1d Binary files /dev/null and b/sample/length/src/commonMain/resources/korge/korge.png differ diff --git a/sample/length/src/commonTest/kotlin/test.kt b/sample/length/src/commonTest/kotlin/test.kt new file mode 100644 index 0000000..666f779 --- /dev/null +++ b/sample/length/src/commonTest/kotlin/test.kt @@ -0,0 +1,26 @@ +import com.soywiz.klock.* +import com.soywiz.korge.input.* +import com.soywiz.korge.tests.* +import com.soywiz.korge.tween.* +import com.soywiz.korge.view.* +import com.soywiz.korim.color.* +import com.soywiz.korma.geom.* +import kotlin.test.* + +class MyTest : ViewsForTesting() { + @Test + fun test() = viewsTest { + val log = arrayListOf() + val rect = solidRect(100, 100, Colors.RED) + rect.onClick { + log += "clicked" + } + assertEquals(1, views.stage.numChildren) + rect.simulateClick() + assertEquals(true, rect.isVisibleToUser()) + tween(rect::x[-102], time = 10.seconds) + assertEquals(Rectangle(x=-102, y=0, width=100, height=100), rect.globalBounds) + assertEquals(false, rect.isVisibleToUser()) + assertEquals(listOf("clicked"), log) + } +} \ No newline at end of file