summaryrefslogtreecommitdiffstats
path: root/_log
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-12-21 08:09:33 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-12-21 08:09:33 +0800
commit8f99ca06fd48386bee511d33d1207f8eaf8bb8f4 (patch)
tree52ff3b9075e2addc21d33da6b9f343c99b17f24d /_log
parentaad38bc831c8bba90688df2cc28c46a46cac1112 (diff)
downloadwww-8f99ca06fd48386bee511d33d1207f8eaf8bb8f4.tar.gz
Matrix
Diffstat (limited to '_log')
-rw-r--r--_log/matrix-digital-rain.md27
1 files changed, 14 insertions, 13 deletions
diff --git a/_log/matrix-digital-rain.md b/_log/matrix-digital-rain.md
index 0a3d30d..b1c5e6c 100644
--- a/_log/matrix-digital-rain.md
+++ b/_log/matrix-digital-rain.md
@@ -12,13 +12,12 @@ rel="noopener noreferrer">Fakesteak</a>: a beautifully lean rendition of the
Matrix rain in raw C using ANSI escape sequences—zero dependencies, not even
ncurses.
-The project's README noted that it didn't support Japanese characters and that
-it used 8-bit color mode. The latter meant that the ghosting effect has to rely
-on different foreground colors rather than shades of the same color.
-
-As a tip of the hat to Domsson's impressive work, I decided to add Unicode and
-24-bit truecolor support to it, aiming to faithfully recreate the original
-Matrix from the first movie during Neo and Cypher's conversation:
+To keep things simple, Fakesteak didn't support Japanese characters and that it
+used 8-bit color mode. The latter meant that the ghosting effect has to rely on
+different foreground colors rather than shades of the same color. As a tip of
+the hat to Domsson's impressive work, I decided to add Unicode and 24-bit
+truecolor support to it, aiming to faithfully recreate the original Matrix from
+the first movie during Neo and Cypher's conversation:
<video style="max-width:100%;" controls="" poster="poster.png">
<source src="matrix.mp4" type="video/mp4">
@@ -27,8 +26,8 @@ Matrix from the first movie during Neo and Cypher's conversation:
Adding Unicode support via `wchar_t` and `wprintf()` was easy enough.
Implementing the ghosting effect with truecolor support, however, turned out
harder than expected. To achieve the ghosting effect, I treated phosphor decay
-as a multiplier, allowing me to emulate a dim afterglow by gradually
-transitioning each raindrop's RGB values towards the background color:
+as a multiplier, which allowed me to emulate the dim afterglow by gradually
+transitioning each raindrop's color towards the background color:
```
static void mat_shade(matrix *mat, size_t row, size_t col)
@@ -46,11 +45,13 @@ made. Instead of using a dedicated buffer, I should have bit-packed the
phosphor decay into the RGB data buffer to save memory. I'm not entirely
satisfied with the Unicode support as it's restricted to contiguous code
points. The glitch effect, which I implemented with characters unexpectedly
-changing, really should flash white as well.
+changing, would have been closer to the original if flashed white as well.
-Nonetheless, the rain closely resembles the original, is highly customizable,
-and is gentle on the CPU. Not too bad for a weekend project. I tested the
-program with xterm and urxvt terminal emulators on OpenBSD and Arch Linux
+Nonetheless, the rain resembles the original with high visual fidelity. It's
+highly customizable and gentle on the CPU. On my 14" ThinkPad T490, which has a
+resolution of 1920x1080 and 4GHz CPU, it uses 2-3% of the CPU with occasional
+jumps of up to about 8%. Not too bad for a weekend project. The program has
+been tested with xterm and urxvt terminal emulators on OpenBSD and Arch Linux
systems. Someone has managed to get it moving on a Raspberry Pi as well.
Lastly, to compile and run: