mirror of
https://github.com/Kapendev/parin.git
synced 2025-04-26 13:09:56 +03:00
Added 9-patch and example for that.
This commit is contained in:
parent
59a351c384
commit
17ba4318ec
3 changed files with 114 additions and 0 deletions
22
examples/intro/patch.d
Normal file
22
examples/intro/patch.d
Normal 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);
|
Loading…
Add table
Add a link
Reference in a new issue