mirror of
https://github.com/jlengrand/korge-samples.git
synced 2026-03-10 08:31:18 +00:00
Add 9-patch sample
This commit is contained in:
1
ninepatch/.gitignore
vendored
Normal file
1
ninepatch/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
7
ninepatch/build.gradle.kts
Normal file
7
ninepatch/build.gradle.kts
Normal file
@@ -0,0 +1,7 @@
|
||||
import com.soywiz.korge.gradle.*
|
||||
|
||||
apply<KorgeGradlePlugin>()
|
||||
|
||||
korge {
|
||||
id = "com.soywiz.samples.ninepatch"
|
||||
}
|
||||
21
ninepatch/src/commonMain/kotlin/main.kt
Normal file
21
ninepatch/src/commonMain/kotlin/main.kt
Normal file
@@ -0,0 +1,21 @@
|
||||
import com.soywiz.kmem.*
|
||||
import com.soywiz.korge.*
|
||||
import com.soywiz.korge.input.*
|
||||
import com.soywiz.korge.view.*
|
||||
import com.soywiz.korim.bitmap.*
|
||||
import com.soywiz.korim.color.*
|
||||
import com.soywiz.korio.file.std.*
|
||||
|
||||
suspend fun main() = Korge(width = 512, height = 512, bgcolor = Colors["#2b2b2b"]) {
|
||||
val ninePath = resourcesVfs["image.9.png"].readNinePatch()
|
||||
|
||||
val np = ninePatch(ninePath, 320.0, 32.0) {
|
||||
position(100, 100)
|
||||
}
|
||||
np.mouse {
|
||||
moveAnywhere {
|
||||
np.width = it.currentPosLocal.x.clamp(16.0, 1000.0)
|
||||
np.height = it.currentPosLocal.y.clamp(16.0, 1000.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
ninepatch/src/commonMain/resources/image.9.png
Normal file
BIN
ninepatch/src/commonMain/resources/image.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.8 KiB |
Reference in New Issue
Block a user