wip(0.S2): migrate - a var nothing writes becomes a let; a state is keyed by its module, directory or program, so every program's plan agrees; paths normalized; program states named SceneDemoState / scene_demo_st; the LSP reads state, mut and entry/handler parameters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3eda72e8c2
commit
5ffe50ed02
463 changed files with 72045 additions and 67421 deletions
|
|
@ -4,32 +4,30 @@
|
|||
import "ludic.ui"
|
||||
program UiEase {
|
||||
numbers float
|
||||
state UieaseState {
|
||||
dim: bool = false
|
||||
now: float = 0.0
|
||||
}
|
||||
view Ease (uiease_st: UieaseState) {
|
||||
dim = uiease_st.dim
|
||||
var dim: bool = false
|
||||
var now: float = 0.0
|
||||
view Ease {
|
||||
dim = dim
|
||||
}
|
||||
const STYLE: string = "<style>@keyframes slide { from { left: 0 } to { left: 37 } }\n.go { animation: slide 0.25s }\n.soft { transition: opacity 0.25s }\n.dim { opacity: 0.2 }</style>"
|
||||
const BODY: string = "<p class='go'>a</p><p class=\"soft {dim ? 'dim' : ''}\">b</p><p class='dim'>c</p></screen>"
|
||||
function clock(uiease_st: UieaseState) -> float { return uiease_st.now }
|
||||
function nodes(ui_st: mut UiState, name: string) -> UiNode {
|
||||
ui_show(ui_st, name, view_ease(), 0.0, 0.0, 200.0, 200.0)
|
||||
return ui_nodes(ui_st, name, view_ease())
|
||||
function clock() -> float { return now }
|
||||
function nodes(name: string) -> UiNode {
|
||||
ui_show(name, view_ease(), 0.0, 0.0, 200.0, 200.0)
|
||||
return ui_nodes(name, view_ease())
|
||||
}
|
||||
# one rate, on its own screen: the slide from its first frame, the fade from half a second in
|
||||
function at_rate(ui_st: mut UiState, uiease_st: mut UieaseState, hz: int) -> string {
|
||||
function at_rate(hz: int) -> string {
|
||||
let name = `r{hz}`
|
||||
uiease_st.dim = false
|
||||
dim = false
|
||||
var mid = ""
|
||||
var slid = false
|
||||
var landed = false
|
||||
var over = false
|
||||
for k in 0 .. hz + 1 {
|
||||
uiease_st.now = float(k) / float(hz)
|
||||
if k == hz / 2 { uiease_st.dim = true }
|
||||
let r = nodes(ui_st, name)
|
||||
now = float(k) / float(hz)
|
||||
if k == hz / 2 { dim = true }
|
||||
let r = nodes(name)
|
||||
let go = r.children[0]
|
||||
let soft = r.children[1]
|
||||
let want = r.children[2].alpha
|
||||
|
|
@ -41,17 +39,17 @@ program UiEase {
|
|||
}
|
||||
return `{hz}: {mid} slid {slid} landed {landed} left {over}`
|
||||
}
|
||||
entry (ui_st: mut UiState, uiease_st: mut UieaseState) {
|
||||
ui_backend(ui_st, new UiBackend)
|
||||
ui_clock(ui_st, fn clock)
|
||||
entry {
|
||||
ui_backend(new UiBackend)
|
||||
ui_clock(fn clock)
|
||||
var page = "<ui>" + STYLE
|
||||
for i in 0 .. 4 {
|
||||
let hz = 60 * (i + 1)
|
||||
page = page + `<screen name='r{hz}'>` + BODY
|
||||
}
|
||||
ui_load_text(ui_st, page + "</ui>", "e.xml")
|
||||
ui_load_text(page + "</ui>", "e.xml")
|
||||
var out = ""
|
||||
for i in 0 .. 4 { out = out + at_rate(ui_st, uiease_st, 60 * (i + 1)) + "; " }
|
||||
for i in 0 .. 4 { out = out + at_rate(60 * (i + 1)) + "; " }
|
||||
print(out)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue