nathanrooy/mnist-matrix

A MacOS screensaver that recreates The Matrix "digital rain" effect using only handwritten digits from the MNIST dataset.

0

stars

3

commits

Swift

primary language

Aug 21, 2026

updated

digital-rain
macos
matrix
matrix-animation
matrix-rain
screensaver
the-matrix
the-matrix-digital-rain

README

MNIST Matrix Screen Saver

A native macOS screen saver that recreates The Matrix "digital rain" effect using handwritten digits from the MNIST dataset.

https://github.com/user-attachments/assets/7f075083-ae36-46e4-92ab-50a61d03e622

macOS Screen Saver Language License

Quick Start & Building

If you're on an Apple Silicon Mac, you can simply download and unzip the pre-built screen saver that's already included in this repository (build/MNISTMatrix.saver.zip).

If you're on an Intel based Mac, or you just want to build it yourself, you can do so with the following commands:

# 1. Clone the repository
git clone https://github.com/nathanrooy/mnist-matrix.git
cd mnist-matrix

# 2. Build and Install (Auto-detects Apple Silicon or Intel)
./build.sh

# Or explicitly target architecture:
./build.sh arm64     # Apple Silicon M1 / M2 / M3 / M4
./build.sh x86_64    # Intel Macs

# 3. Test & Preview in System Settings
open "$HOME/Library/Screen Savers/MNISTMatrix.saver"

Core Configuration Parameters

All visual parameters are defined at the top of src/MNISTMatrixSaverView.swift:

ParameterTypeDefaultDescription
minFallSpeedRowsPerSecondDouble6.0Minimum fall speed for a rain stream (rows/sec)
maxFallSpeedRowsPerSecondDouble12.0Maximum fall speed for a rain stream (rows/sec)
minDropLengthRowsInt8Minimum digit tail length of rain streams
maxDropLengthRowsInt36Maximum digit tail length of rain streams
densityRatioDouble0.50Fraction of screen columns containing active streams (0.3 to 1.0)
baseDigitSizeCGFloat18.0Grid cell & digit size in pixels
digitSwapProbabilityDouble0.50Fraction of falling digits that morph/swap (0.0 to 1.0)
minSwapDelaySecondsDouble0.25Minimum delay in seconds before a digit swaps
maxSwapDelaySecondsDouble1.25Maximum delay in seconds before a digit swaps
showFPSOverlayBooltrueToggles yellow FPS counter overlay in top-right corner

Generating the Binary Atlas (Optional)

The pre-built resources/mnist_atlas.bin asset atlas (7.49 MB) is included in the repository. If however, you want to extract resources/mnist_atlas.bin yourself from the raw MNIST dataset (data/test-00000-of-00001.parquet):

# Requires Python 3 with pyarrow and Pillow
python3 scripts/munge.py

Directory Structure

mnist-matrix/
├── README.md                      # Project documentation and guide
├── build.sh                       # Pure Swift build script (compiles, signs & installs)
├── data/
│   └── test-00000-of-00001.parquet# 10,000 row raw MNIST Parquet dataset
├── resources/
│   └── mnist_atlas.bin            # Pre-generated binary atlas (10,000 28x28 grayscale digits)
├── scripts/
│   └── munge.py                   # Python script to convert Parquet -> mnist_atlas.bin
└── src/
    ├── Info.plist                 # Screen saver bundle property list
    ├── MNISTAtlas.swift           # Memory-mapped binary atlas loader & scaled pixel cache
    └── MNISTMatrixSaverView.swift # Subclass of ScreenSaverView & DirectScreenRenderer

Requirements

  • macOS 12.0 (Monterey) or newer (Fully Sonoma, Sequoia, and Tahoe compatible).
  • Swift Command Line Tools (swiftc, included with Xcode / Command Line Tools).

License

MIT License. Feel free to use, modify, and distribute!

Contributors

nathanrooy

3 commits

nathanrooy/mnist-matrix

A MacOS screensaver that recreates The Matrix "digital rain" effect using only handwritten digits from the MNIST dataset.

0

stars

3

commits

Swift

primary language

Aug 21, 2026

updated

digital-rain
macos
matrix
matrix-animation
matrix-rain
screensaver
the-matrix
the-matrix-digital-rain

README

MNIST Matrix Screen Saver

A native macOS screen saver that recreates The Matrix "digital rain" effect using handwritten digits from the MNIST dataset.

https://github.com/user-attachments/assets/7f075083-ae36-46e4-92ab-50a61d03e622

macOS Screen Saver Language License

Quick Start & Building

If you're on an Apple Silicon Mac, you can simply download and unzip the pre-built screen saver that's already included in this repository (build/MNISTMatrix.saver.zip).

If you're on an Intel based Mac, or you just want to build it yourself, you can do so with the following commands:

# 1. Clone the repository
git clone https://github.com/nathanrooy/mnist-matrix.git
cd mnist-matrix

# 2. Build and Install (Auto-detects Apple Silicon or Intel)
./build.sh

# Or explicitly target architecture:
./build.sh arm64     # Apple Silicon M1 / M2 / M3 / M4
./build.sh x86_64    # Intel Macs

# 3. Test & Preview in System Settings
open "$HOME/Library/Screen Savers/MNISTMatrix.saver"

Core Configuration Parameters

All visual parameters are defined at the top of src/MNISTMatrixSaverView.swift:

ParameterTypeDefaultDescription
minFallSpeedRowsPerSecondDouble6.0Minimum fall speed for a rain stream (rows/sec)
maxFallSpeedRowsPerSecondDouble12.0Maximum fall speed for a rain stream (rows/sec)
minDropLengthRowsInt8Minimum digit tail length of rain streams
maxDropLengthRowsInt36Maximum digit tail length of rain streams
densityRatioDouble0.50Fraction of screen columns containing active streams (0.3 to 1.0)
baseDigitSizeCGFloat18.0Grid cell & digit size in pixels
digitSwapProbabilityDouble0.50Fraction of falling digits that morph/swap (0.0 to 1.0)
minSwapDelaySecondsDouble0.25Minimum delay in seconds before a digit swaps
maxSwapDelaySecondsDouble1.25Maximum delay in seconds before a digit swaps
showFPSOverlayBooltrueToggles yellow FPS counter overlay in top-right corner

Generating the Binary Atlas (Optional)

The pre-built resources/mnist_atlas.bin asset atlas (7.49 MB) is included in the repository. If however, you want to extract resources/mnist_atlas.bin yourself from the raw MNIST dataset (data/test-00000-of-00001.parquet):

# Requires Python 3 with pyarrow and Pillow
python3 scripts/munge.py

Directory Structure

mnist-matrix/
├── README.md                      # Project documentation and guide
├── build.sh                       # Pure Swift build script (compiles, signs & installs)
├── data/
│   └── test-00000-of-00001.parquet# 10,000 row raw MNIST Parquet dataset
├── resources/
│   └── mnist_atlas.bin            # Pre-generated binary atlas (10,000 28x28 grayscale digits)
├── scripts/
│   └── munge.py                   # Python script to convert Parquet -> mnist_atlas.bin
└── src/
    ├── Info.plist                 # Screen saver bundle property list
    ├── MNISTAtlas.swift           # Memory-mapped binary atlas loader & scaled pixel cache
    └── MNISTMatrixSaverView.swift # Subclass of ScreenSaverView & DirectScreenRenderer

Requirements

  • macOS 12.0 (Monterey) or newer (Fully Sonoma, Sequoia, and Tahoe compatible).
  • Swift Command Line Tools (swiftc, included with Xcode / Command Line Tools).

License

MIT License. Feel free to use, modify, and distribute!

Contributors

nathanrooy

3 commits

Languages

Swift

85.0%

Shell

8.0%

Python

7.0%