diff --git a/ninepatch/.gitignore b/ninepatch/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/ninepatch/.gitignore @@ -0,0 +1 @@ +/build diff --git a/ninepatch/build.gradle.kts b/ninepatch/build.gradle.kts new file mode 100644 index 0000000..5c835e5 --- /dev/null +++ b/ninepatch/build.gradle.kts @@ -0,0 +1,7 @@ +import com.soywiz.korge.gradle.* + +apply() + +korge { + id = "com.soywiz.samples.ninepatch" +} diff --git a/ninepatch/src/commonMain/kotlin/main.kt b/ninepatch/src/commonMain/kotlin/main.kt new file mode 100644 index 0000000..863f606 --- /dev/null +++ b/ninepatch/src/commonMain/kotlin/main.kt @@ -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) + } + } +} diff --git a/ninepatch/src/commonMain/resources/image.9.png b/ninepatch/src/commonMain/resources/image.9.png new file mode 100644 index 0000000..063c03e Binary files /dev/null and b/ninepatch/src/commonMain/resources/image.9.png differ