GitHub - minimaxir/ballin: A colorful interactive physics simulator with thousands of balls, but in your terminal! · GitHub

Source: original

ballin

Crates.io

A colorful interactive physics simulator with thousands of balls, but in your terminal!

ballin is a fun TUI app written in Rust that simulates thousands of logical balls, but despite the inherent character constraints of a terminal, you can see the realistic physics of the balls in action:

Watch the color explosion in action!

ballin.mp4

Disclosure: This crate was developed with the assistance of Claude Opus 4.5 initially to answer the shower thought "would the Braille Unicode trick work to visually simulate complex ball physics in a terminal?" Opus 4.5 one-shot the problem, so I decided to further experiment to make it more fun and colorful. The full list of prompts used with Claude Code is present in PROMPTS.md.

Installation

The app binaries can be downloaded from the Releases page for your platform of choice, or by using the following terminal commands:

macOS Apple Silicon

curl -sL https://github.com/minimaxir/ballin/releases/latest/download/ballin-macos-arm.tar.gz | tar xz

macOS Intel

curl -sL https://github.com/minimaxir/ballin/releases/latest/download/ballin-macos-intel.tar.gz | tar xz

Linux ARM64

curl -sL https://github.com/minimaxir/ballin/releases/latest/download/ballin-linux-arm64.tar.gz | tar xz

Linux x64

curl -sL https://github.com/minimaxir/mballin/releases/latest/download/ballin-linux.tar.gz | tar xz

For Windows, download and unzip the binary from here.

If Rust is installed, you can install the crate directly via cargo:

cargo install ballin

Example Usage

It is VERY strongly recommended to use a terminal emulator such asGhostty as normal terminals may have their frame rates capped at 30 FPS and the output looks choppy. The app looks comparatively poor in the native macOS Terminal.app, for example.

To run ballin: if you downloaded the binary, run it in the terminal with ./ballin. If you installed via Rust, run cargo run. The physics simulation will start with some shape objects randomly present to let the hilarity ensue immediately!

Press keys, click areas, see what happens? You can press ? for the full list of keyboard shortcuts.

Balls can be added to the machine by clicking the upper area: you can also hold Space to drop balls from all areas, or Shift+1/2/3/4/5/6 to drop balls in a specific section. You can also open Options to change the number of balls manually to a specified value, or Reset to return to the base number of balls.

For terminal compatability and accessibility reasons, Color Mode is disabled by default. To toggle it, just click the appropriately colorful Colors button (or press c) and the colors will appear! When triggering a geyser, it will color all affected balls the corresponding color.

Shapes can be inserted from the Shape menu. You can also click a Shape to select it: use the arrow keys to move a selected shape, press n/m to cycle through colors for the shape, or click-and-hold to drag the shape around.

Levels, which include options and shape objects, can be exported using Save and loaded using Load. The ballin level used in the video above is available in the level.json file.

You can also use the CLI arguments of --color to enable color by default, or --balls 10000 to increase the default number of starting balls.

Notes

Maintainer/Creator

Max Woolf (@minimaxir)

Max's open-source projects are supported by hisPatreon and GitHub Sponsors. If you found this project helpful, any monetary contributions to the Patreon are appreciated and will be put to good creative use.

License

MIT