diff options
| author | user <user@clank> | 2026-08-17 14:22:38 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-17 14:22:38 +0200 |
| commit | ec91ccffe631ae34b111bf6161fd0e3c487f684c (patch) | |
| tree | 4a9fdbb720d9bf03edd5f538d1d87afd2bf51bfb /src/shader.c | |
| parent | sl0ppty: clang-format, and a hook that runs it on what you staged (diff) | |
| download | slosh-ec91ccffe631ae34b111bf6161fd0e3c487f684c.tar.gz slosh-ec91ccffe631ae34b111bf6161fd0e3c487f684c.tar.xz slosh-ec91ccffe631ae34b111bf6161fd0e3c487f684c.zip | |
sl0ppty: clang-format the tree
The bumpy one. `make fmt` over every `.c` and `.h` outside `vendor/`: 32 files,
1,843 lines rewritten, no behaviour changed. Nothing here is worth reading -- the
next commit adds it to `.git-blame-ignore-revs` so `git blame` walks past it.
Two thirds of it is alignment the formatter now owns: trailing comments in a
struct, continuation lines under a signature. The rest is the hand-packed tables
opening up to one entry per line -- `ACTIONS`, `NAMED_KEYS`, `ACTION_HELP`. That
is a real loss of density and a real gain in diffs: adding an action was a reflow
of the block and is now one line. Anything worth keeping packed can be fenced with
`// clang-format off`; nothing was, on the grounds that a table is the thing a
formatter is for.
**One change is not formatting.** `src/config.h` had three trailing comments glued
onto one field:
uint16_t hover_delay_ms; /* how long the pointer must rest to arm a guide */
/* how long an announcement stays up */ /* rows per wheel notch */
-- `toast_ms`'s and `scroll_lines`' comments, landed on their neighbour by an
earlier edit, documenting the wrong things ever since. It is in this commit
because it is what caught it: clang-format could not settle on that line, wrapping
it one way and then re-indenting the wrap on a second pass, so `make fmt` was not
idempotent. The comments are back where they belong and it is.
Verified after the reformat, not before: `make clean && make all` is
warning-free, `make retest` is 1801 checks green, and `make fmt` twice in a row
changes nothing the second time. A formatter that alters behaviour would be worse
than none, so the gate was the whole suite rather than a reading of the diff.
Diffstat (limited to 'src/shader.c')
| -rw-r--r-- | src/shader.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/src/shader.c b/src/shader.c index 56a0a2b..6f24564 100644 --- a/src/shader.c +++ b/src/shader.c @@ -20,8 +20,8 @@ static uint8_t mix8(uint8_t from, uint8_t to, uint8_t amount) { } static color_t mix(color_t from, color_t to, uint8_t amount) { - return (color_t){true, mix8(from.r, to.r, amount), - mix8(from.g, to.g, amount), mix8(from.b, to.b, amount)}; + return (color_t){true, mix8(from.r, to.r, amount), mix8(from.g, to.g, amount), + mix8(from.b, to.b, amount)}; } /* Rec. 601 luma. The green weight is not a rounding error: the eye is far more @@ -84,10 +84,22 @@ static void sh_vignette(const shader_t *sh, const shade_ctx_t *ctx, cell_t *c) { static void sh_gradient(const shader_t *sh, const shade_ctx_t *ctx, cell_t *c) { int span, pos; switch (sh->param) { - case 1: span = ctx->rows; pos = ctx->rows - 1 - ctx->y; break; - case 2: span = ctx->cols; pos = ctx->x; break; - case 3: span = ctx->cols; pos = ctx->cols - 1 - ctx->x; break; - default: span = ctx->rows; pos = ctx->y; break; + case 1: + span = ctx->rows; + pos = ctx->rows - 1 - ctx->y; + break; + case 2: + span = ctx->cols; + pos = ctx->x; + break; + case 3: + span = ctx->cols; + pos = ctx->cols - 1 - ctx->x; + break; + default: + span = ctx->rows; + pos = ctx->y; + break; } if (span <= 1) return; uint8_t a = (uint8_t)((int)sh->amount * pos / (span - 1)); @@ -126,8 +138,8 @@ static void sh_spotlight(const shader_t *sh, const shade_ctx_t *ctx, if (!ctx->has_cursor) return; int r = sh->param ? sh->param : 10; int inner = r * r; - int d = dist2((int)ctx->x - (int)ctx->cursor_x, - (int)ctx->y - (int)ctx->cursor_y); + int d = + dist2((int)ctx->x - (int)ctx->cursor_x, (int)ctx->y - (int)ctx->cursor_y); if (d <= inner) return; int ramp = inner * 3; int over = d - inner; @@ -188,8 +200,11 @@ bool shader_make_p(shader_t *out, const char *kind, color_t color, if (!d) return false; /* channels left 0, which the pass reads as both: a shader made here has no * opinion about that, and the config sets it when the config has one. */ - *out = (shader_t){.kind = d->name, .fn = d->fn, .color = color, - .amount = amount, .param = param}; + *out = (shader_t){.kind = d->name, + .fn = d->fn, + .color = color, + .amount = amount, + .param = param}; return true; } @@ -403,8 +418,10 @@ void shade_apply(screen_t *s, const shader_t *shaders, size_t n, rect_t r, * reused for as long as nothing it reads has changed. One that does * read the clock is evaluated per cell, per frame, which is what * asking for animation costs. */ - if (expr_amount_map(sh->amount_expr, &env, &m)) map = m; - else per_cell = true; + if (expr_amount_map(sh->amount_expr, &env, &m)) + map = m; + else + per_cell = true; } } |
