summaryrefslogtreecommitdiffstats
path: root/_projects/matrix-digital-rain.md
diff options
context:
space:
mode:
Diffstat (limited to '_projects/matrix-digital-rain.md')
-rw-r--r--_projects/matrix-digital-rain.md40
1 files changed, 23 insertions, 17 deletions
diff --git a/_projects/matrix-digital-rain.md b/_projects/matrix-digital-rain.md
index 35a3d97..7c5f295 100644
--- a/_projects/matrix-digital-rain.md
+++ b/_projects/matrix-digital-rain.md
@@ -6,37 +6,43 @@ layout: post
---
"All I see is blonde, brunette, red head." The iconic digital rain from The
-Matrix, implemented in C, without dependencies (not even ncurses).
+Matrix implemented in C without dependencies (not even ncurses).
<video style="max-width:100%;" controls="" poster="thumb.png">
<source src="matrix.mp4" type="video/mp4">
</video>
-This project is a fork of Domsson's beautiful <a
+## Overview
+
+This is my fork of Domsson's beautiful <a
href="https://github.com/domsson/fakesteak" class="external" target="_blank"
-rel="noopener noreferrer">Fakesteak</a>. Use the following commands to compile
-and run the program:
+rel="noopener noreferrer">Fakesteak</a>. As I was going through the fakesteak
+code, I thought about what it might take to recreate the original rain from the
+first Matrix movie without losing the program's minimalism and elegance.
+
+My version of the matrix has the following features:
+
+ - Unicode characters.
+ - Fully customizable 24-bit RGB (truecolor) colors.
+ - Glitches in the matrix.
+ - Ghosting effect of old monochrome displays.
+ - Closely resembles the one seen in the background while Neo and Cypher were
+ talking in the first Matrix movie.
+
+As there are no dependencies, you can compile and run it however you want:
```
$ cc -O3 main.c -o matrix
$ ./matrix
```
-While I loved Domsson's take on the
-digital rain, what blew my mind was the minimalistic elegance of his code. As I
-carefully examined it, I thought about what it might take to recreate the
-original digital rain from the first Matrix movie with it. The challenge is
-adding these features without destroying fakesteak's elegance.
-
## How does it work?
-The `matrix` struct makes use of three 2D arrays to encode the Matrix: the
-`code` array for 32-bit Unicode characters, the `rgb` array for 24-bit RGB
-values of the character (foreground color), and the `shade` array for the
-degree of transparency of the character to simulate the ghosting effect of old
-monochrome displays. The dimensions of these arrays depend on the size of the
-terminal screen. Each slot in the array corresponds to a cursor position on the
-screen.
+The `matrix` struct makes use of two 2D arrays to encode the Matrix: the `code`
+array for 32-bit Unicode characters and the `rgb` array for RGB values of the
+characters (foreground color). The dimensions of these arrays depend on the
+size of the terminal window. Each slot in the array corresponds to a cursor
+position on the screen.
The ghosting effect, which is arguably the crowning feature of my version, is
implemented by carefully scaling and mixing the RGB channels: