feat(ui): nine-slice corners clamped to half the box in each direction, cut on whole pixels

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-24 21:59:26 +03:00
parent 12f4ba8431
commit cf8b9e425e
9 changed files with 53 additions and 7 deletions

View file

@ -0,0 +1,19 @@
# ui_nine.ludic — a nine-slice's cuts: its corners are at most half the box across and half of it
# down, each direction on its own, so a key cap shorter than two corners keeps them across; the cuts
# land on whole pixels so the pieces meet.
import "ludic.ui"
program UiNine {
numbers float
function cuts(x: float, y: float, w: float, h: float, dst: float) -> string {
let c = ui_nine_cuts(x, y, w, h, dst)
var s = ""
for i in 0 .. 8 {
if i == 4 { s = s + "/" }
s = s + ` {int(c[i])}`
}
return s
}
entry {
print(`cap{cuts(0.0, 0.0, 30.0, 16.0, 12.0)} | wide{cuts(0.0, 0.0, 100.0, 40.0, 12.0)} | odd{cuts(10.4, 3.6, 20.3, 9.0, 14.0)}`)
}
}