Added 9-patch and example for that.

This commit is contained in:
Kapendev 2024-12-31 16:23:40 +02:00
parent 59a351c384
commit 17ba4318ec
3 changed files with 114 additions and 0 deletions

22
examples/intro/patch.d Normal file
View file

@ -0,0 +1,22 @@
/// This example shows how to draw a 9-patch texture in Parin.
import parin;
auto atlas = TextureId();
auto patchAtlasArea = Rect(5 * 16, 1 * 16, Vec2(16 * 3));
void ready() {
lockResolution(320, 180);
atlas = loadTexture("atlas.png");
}
bool update(float dt) {
auto start = Vec2(8);
// Draw a 9-patch texture with a size based on the mouse position.
drawTexturePatch(atlas, patchAtlasArea, Rect(start, mouse - start), true);
return false;
}
void finish() { }
mixin runGame!(ready, update, finish);