diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2025-12-26 16:53:45 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2025-12-26 21:43:43 +0800 |
| commit | e04ce2ab6ca82d0014bec8b217215f35b436ff25 (patch) | |
| tree | 4fdc82fb2bf46de34213cf7b2d3f1a5abed0b7be /_site/log/matrix-digital-rain | |
| parent | 9b95f811472a15280e67f99c90c0013987b32ee2 (diff) | |
| download | www-e04ce2ab6ca82d0014bec8b217215f35b436ff25.tar.gz | |
FPM lock journal style.
Diffstat (limited to '_site/log/matrix-digital-rain')
| -rw-r--r-- | _site/log/matrix-digital-rain/index.html | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/_site/log/matrix-digital-rain/index.html b/_site/log/matrix-digital-rain/index.html index f254ed2..8383776 100644 --- a/_site/log/matrix-digital-rain/index.html +++ b/_site/log/matrix-digital-rain/index.html @@ -54,45 +54,48 @@ than it needed to be.</p> </video> <p>Moved phosphor decay into the 4th byte of the RGB union–should’ve done this -in 2022. What was I thinking.</p> +in 2022; What was I thinking.</p> <p>Keeping the RGB union despite portability concerns. All my systems are little-endian and the code is cleaner this way.</p> <p>Fixed Unicode by introducing a charset array. UNICODE(min, max) packs Unicode -ranges into uint64–low four bytes for start, high four bytes for end. +ranges into uint64: low four bytes for start, high four bytes for end. insert_code() unpacks a random block and picks a character from it:</p> -<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>static uint64_t glyphs[] = { +<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#define UNICODE(min, max) (((uint64_t)max << 32) | min) + +static uint64_t glyphs[] = { UNICODE(0x0021, 0x007E), /* ASCII */ UNICODE(0xFF65, 0xFF9F), /* Half-width Katakana */ }; -</code></pre></div></div> - -<p>Full-width Katakana breaks column alignment. Stick to half-width -(U+FF61-U+FF9F) range. Compile with -DNOKANA to disable Katakana altogether.</p> -<p>blend() simulates phosphor decay by eroding RGB channels toward -background color:</p> - -<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>static inline void blend(matrix *mat, size_t row, size_t col) +static inline void insert_code(matrix *mat, + size_t row, size_t col) { - unsigned char *color = mat->rgb[index(mat, row, col)].color; - color[R] = color[R] - (color[R] - RGB_BG_RED) / DECAY_MPLIER; - color[G] = color[G] - (color[G] - RGB_BG_GRN) / DECAY_MPLIER; - color[B] = color[B] - (color[B] - RGB_BG_BLU) / DECAY_MPLIER; + uint64_t blk; + uint32_t min, max; + + blk = glyphs[(rand() % glyphlen)]; + min = (uint32_t)blk; + max = (uint32_t)(blk >> 32); + mat->code[index(mat, row, col)] = rand() % (max - min) + min; } </code></pre></div></div> -<p>That’s still good. Leaving it alone.</p> +<p>Full-width Katakana breaks column alignment. Stick to half-width +(U+FF61-U+FF9F) range. Compile with -DNOKANA to disable Katakana altogether.</p> + +<p>blend() is still good. Leaving it alone.</p> <p>Tossed license and automake cruft. Just <code class="language-plaintext highlighter-rouge">cc -O3 main.c -o matrix</code> now. Don’t need the ceremony.</p> -<p>Runs at 2-3% CPU on OpenBSD (T490). No regressions. Fans are quiet.</p> +<p>Runs at 2-3% CPU on OpenBSD (T490). No cause to measure performance more +precisely. No regressions. Fans are quiet.</p> <p>Commit: -<a href="https://git.asciimx.com/matrix-digital-rain/commit/?id=03f8d87ba7c2e46bd3f3cc4c772fb3a2ac740c92">03f8d87</a></p> +<a href="https://git.asciimx.com/matrix-digital-rain/commit/main.c?id=69a888a5b0bc4ef4bce4f86c1556a06f0f131fda">69a888a</a></p> </div> <p class="post-author right">by W. D. Sadeep Madurange</p> </div> |
