summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--_log/matrix-digital-rain.md33
1 files changed, 32 insertions, 1 deletions
diff --git a/_log/matrix-digital-rain.md b/_log/matrix-digital-rain.md
index 78fe623..af3cff6 100644
--- a/_log/matrix-digital-rain.md
+++ b/_log/matrix-digital-rain.md
@@ -49,7 +49,38 @@ static inline void insert_code(matrix *mat,
Full-width Katakana breaks column alignment. Stick to half-width
(U+FF61-U+FF9F) range. Compile with -DNOKANA to disable Katakana altogether.
-blend() is still good. Leaving it alone.
+blend() for screen decay is still good:
+
+```
+static inline void blend(matrix *mat,
+ size_t row, size_t col)
+{
+ unsigned char *color;
+
+ 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;
+}
+```
+
+Left it alone.
+
+Optimized RNG--xorshift instead of rand():
+
+```
+static inline uint32_t xor(void)
+{
+ /* Xorshift RNGs, George Marsaglia, The Florida State University. */
+ static uint32_t y = 2463534242;
+
+ y ^= (y << 13);
+ y = (y >> 17);
+ return (y ^= (y << 5));
+}
+```
+
+NOTE: Non-linear variations (xorshitr+) for more speed.
Tossed license and automake cruft. Just `cc -O3 main.c -o matrix` now. Don't
need the ceremony.