mirror of
https://github.com/jlengrand/korge-samples.git
synced 2026-03-10 08:31:18 +00:00
Add length sample
This commit is contained in:
1
sample/length/.gitignore
vendored
Normal file
1
sample/length/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
8
sample/length/build.gradle.kts
Normal file
8
sample/length/build.gradle.kts
Normal file
@@ -0,0 +1,8 @@
|
||||
import com.soywiz.korge.gradle.*
|
||||
|
||||
apply<KorgeGradlePlugin>()
|
||||
|
||||
korge {
|
||||
id = "com.soywiz.samples.length"
|
||||
targetDefault()
|
||||
}
|
||||
23
sample/length/src/commonMain/kotlin/main.kt
Normal file
23
sample/length/src/commonMain/kotlin/main.kt
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
sample/length/src/commonMain/resources/9patch.9.png
Normal file
BIN
sample/length/src/commonMain/resources/9patch.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.8 KiB |
1
sample/length/src/commonMain/resources/korge.atlas
Normal file
1
sample/length/src/commonMain/resources/korge.atlas
Normal file
@@ -0,0 +1 @@
|
||||
korge
|
||||
BIN
sample/length/src/commonMain/resources/korge.png
Normal file
BIN
sample/length/src/commonMain/resources/korge.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
sample/length/src/commonMain/resources/korge/9patch.9.png
Normal file
BIN
sample/length/src/commonMain/resources/korge/9patch.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.8 KiB |
BIN
sample/length/src/commonMain/resources/korge/korge.png
Normal file
BIN
sample/length/src/commonMain/resources/korge/korge.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
26
sample/length/src/commonTest/kotlin/test.kt
Normal file
26
sample/length/src/commonTest/kotlin/test.kt
Normal file
@@ -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<String>()
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user