Skip to content

Conversation

@ShreyDudie
Copy link

Digital Rain - ASCII Waterfall in Python

closes #1687

This Python script creates a falling ASCII stream effect reminiscent of the "Matrix" digital rain. Characters cascade down the terminal screen, creating a mesmerizing waterfall-like display.


Features

  • Falling characters in each column
  • Randomized character selection from letters, numbers, and symbols
  • Continuous animation with adjustable speed
  • Works in most terminal environments
  • Can be stopped gracefully with Ctrl+C

Requirements

  • Python 3.x
  • Terminal or command line that supports ANSI escape codes

How It Works

  1. Drop Initialization:
    Each column has a "drop" position representing where the next character will appear.

  2. Frame Generation:
    For each frame, a character is printed at the current drop position, while other positions remain empty.

  3. Drop Movement:
    Drops move downwards each frame. Occasionally, they reset to the top, creating a continuous falling effect.

  4. Screen Refresh:
    The screen is redrawn by moving the cursor back to the top-left using ANSI escape codes (\033[H).

  5. Randomized Characters:
    Characters are randomly picked from a set of letters, numbers, and symbols.


Configuration

You can adjust these constants at the top of the script:

WIDTH = 80     # Number of columns
HEIGHT = 24    # Number of rows
SPEED = 0.1    # Delay between frames (seconds)
CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ASCII Waterfall Animation

1 participant