Add 9-patch sample

This commit is contained in:
soywiz
2020-07-11 13:23:13 +02:00
parent a7d17708ac
commit 3d66be5307
4 changed files with 29 additions and 0 deletions

1
ninepatch/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,7 @@
import com.soywiz.korge.gradle.*
apply<KorgeGradlePlugin>()
korge {
id = "com.soywiz.samples.ninepatch"
}

View 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)
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB