aboutsummaryrefslogtreecommitdiffstats
path: root/include/expr.h
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-19 14:30:28 +0200
committeruser <user@clank>2026-08-19 14:30:28 +0200
commit20e1e104f2254c914b464a147aa0368491cdeb0c (patch)
treeea3d1d0618426f7cdad703ad854b4ce07e06e9b3 /include/expr.h
parentslosh: the splash colours glyphs, never backgrounds (diff)
downloadslosh-20e1e104f2254c914b464a147aa0368491cdeb0c.tar.gz
slosh-20e1e104f2254c914b464a147aa0368491cdeb0c.tar.xz
slosh-20e1e104f2254c914b464a147aa0368491cdeb0c.zip
slosh: the logo flies into place -- a particle engine, statelessly
Every non-space glyph of the logo is a particle that flies to its cell over the first two fifths of splash_ms, then *is* the logo for the rest. There is deliberately no particle state anywhere: a position is a pure function of (target, elapsed, seed), recomputed every frame like the layout and the pane states and for the same reason -- physics that is stored can drift, physics that is derived cannot. The seed is the splash timestamp, so every attach flies differently and one splash is coherent frame to frame; a per-particle hash staggers departures, and the delay rescaling lands every straggler exactly at the end, because an almost-assembled logo reads as a bug. Five motions, picked by the clock and pinned by {"cmd":"splash", "motion":N}: rain (fall in, column by column), scatter (converge from everywhere), slide (rows enter from alternating sides), vortex (spiral in around the centre, orbit shrinking and unwinding), shuffle (the glyphs trade places, then sort themselves). The colour chains keep playing over the box throughout, so particles catch their hue as they cross into it. expr_sin() is the expression language's own sine exported for C-side animation: a motion sketched in the repl and one compiled into the binary cannot disagree about what sin(90) is. The tests learned two things the flights taught: the logo's opening run appears three times per line and assembly is staggered, so a middle occurrence can land first -- "assembled" is the row whose first block glyph is where the match begins -- and windows need margins that survive a parallel suite on a busy box.
Diffstat (limited to 'include/expr.h')
-rw-r--r--include/expr.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/expr.h b/include/expr.h
index d593319..28eeabc 100644
--- a/include/expr.h
+++ b/include/expr.h
@@ -93,6 +93,10 @@ int expr_eval(const expr_prog_t *p, const expr_env_t *env);
* pretend an expression was a number. */
const char *expr_source(const expr_prog_t *p);
+/* The language's sine, for C code that animates: degrees in (any angle
+ * wraps), -255..255 out -- the same table `sin()` in an expression uses. */
+int expr_sin(int deg);
+
/* Evaluate for every cell of a cols x rows rect into `out` (cols*rows bytes,
* clamped to 0..255), reusing the last result when nothing it reads has
* changed. Returns false when the program reads the clock, which is the one