Skip to content

Vitexus/fractalus

Repository files navigation

Mandelbrot WebGL Renderer with Mastodon Bot

A high-performance WebGL-based Mandelbrot set renderer that automatically generates colorful screenshots and saves them as SVG files every minute, with optional automatic posting to Mastodon.

Features

  • WebGL Rendering: Hardware-accelerated Mandelbrot set computation using GPU shaders
  • Fullscreen Mode: Immersive full-screen exploration with F key toggle
  • Intelligent Autopilot: Automatic exploration with smart navigation to interesting fractal regions
  • Mouse Wheel Navigation: Precise cursor-centered zooming with smooth control
  • Dedicated Palette Control: Left/right mouse buttons exclusively for color palette stepping
  • Continuous Palette Cycling: Hold mouse buttons for real-time palette animation
  • Circular Color Cycling: Smooth automatic color transitions creating rainbow effects
  • Keyboard Fine-Tuning: Arrow keys for precise color adjustments with multiple step sizes
  • Automatic Screenshots: Captures and saves SVG files every minute automatically
  • Mastodon Integration: Automatically post screenshots to Mastodon with coordinates and parameters
  • Direct Publishing: One-click posting to Mastodon from the browser interface
  • SVG Export: Converts WebGL framebuffer to scalable SVG format
  • Metadata Export: Saves rendering parameters as JSON for social media posting
  • Randomization: Each screenshot uses random zoom levels, positions, and color schemes

Quick Setup with Direct Publishing

# Run setup script
./setup.sh
source venv/bin/activate

# Authenticate with Mastodon
toot login --instance jeansolpartre.com

# Start the web API (in one terminal)
python web_api.py

# Start the file monitor bot (in another terminal)
python mastodon_bot.py

# Open the renderer
# Browser: http://localhost:8000

Now you can use the "📤 Publish to Mastodon" button for instant posting!

Interactive Controls

Navigation

  • Mouse Wheel: Zoom in/out centered on cursor position (scroll up = zoom in, scroll down = zoom out)
  • ⛶ Fullscreen: Toggle full-screen mode for immersive exploration
  • F Key: Quick fullscreen toggle
  • Escape: Exit autopilot mode

Color Palette Control

  • Left Mouse Click: Step to previous palette (-25°)
  • Right Mouse Click: Step to next palette (+25°)
  • Hold Left Mouse: Continuously cycle backward through palettes
  • Hold Right Mouse: Continuously cycle forward through palettes
  • Arrow Keys: Left/Right arrows rotate colors (±15°)
  • Shift + Arrow Keys: Fine color rotation (±5°)
  • R Key: Reset color palette to default

Intelligent Autopilot

  • 🚁 Start Autopilot: Begin automatic exploration mode
  • Smart Navigation: AI-driven movement to interesting fractal regions
  • Zoom Intelligence: Automatically zooms into detailed boundary areas (60% of moves)
  • Area Exploration: Smooth transitions between different fractal regions (20% of moves)
  • Strategic Zoom-Out: Occasionally zooms out to discover new areas (20% of moves)
  • Curated Locations: Visits mathematically interesting points like seahorse valleys and spiral areas
  • Color Integration: Automatically enables color cycling during exploration
  • Smooth Transitions: 2-5 second animated movements with easing
  • Random Timing: 2-8 second intervals between moves for natural exploration
  • Escape to Exit: Press Esc key to stop autopilot and regain manual control

Automation

  • Start Auto-Save: Begin automatic screenshot generation every 60 seconds (saves to Downloads)
  • Stop Auto-Save: Stop the automatic process
  • 📸 Take Screenshot (Choose Location): Manually capture with save dialog to choose filename and location
  • 📤 Publish to Mastodon: Instantly post current view to Mastodon with coordinates
  • 🌈 Color Cycling: Start/stop automatic color palette cycling
  • Cycle Speed: Adjust color cycling speed from 0.1x to 3.0x

One-Command Startup

# Start everything at once
./start_all.sh

This starts:

Press Ctrl+C to stop all services.

Technical Details

WebGL Shaders

  • Vertex shader handles screen-space quad rendering
  • Fragment shader computes Mandelbrot set iterations per pixel
  • HSV to RGB conversion for vibrant color generation

SVG Generation

  • Reads WebGL framebuffer pixel data
  • Groups pixels by color for efficient SVG generation
  • Optimizes output by grouping adjacent pixels into rectangles
  • Includes metadata and timestamps in SVG files

Parameters

Each screenshot randomizes:

  • Zoom Level: 10x to 1000x magnification
  • Center Position: Random complex plane coordinates
  • Color Offset: 0° to 360° hue shift
  • Color Scale: 0.5x to 5.5x color cycling speed
  • Max Iterations: 50 to 250 iterations for detail level

Browser Requirements

  • WebGL support (available in all modern browsers)
  • ES6 JavaScript support
  • File download capabilities

Mastodon Bot Setup

The included Mastodon bot automatically posts your Mandelbrot screenshots to jeansolpartre.com (or any Mastodon server).

Quick Setup

# Run the setup script
chmod +x setup.sh
./setup.sh

# Activate virtual environment  
source venv/bin/activate

# Authenticate with Mastodon
toot login --instance jeansolpartre.com

# Start the bot
python mastodon_bot.py

Bot Features

  • Auto-monitoring: Watches Downloads folder for new mandelbrot-*.svg files
  • Smart posting: Includes coordinates, zoom level, and fractal parameters
  • Image conversion: Converts SVG to PNG for Mastodon compatibility
  • Hashtags: Automatically adds #Mandelbrot #Fractals #GenerativeArt #Mathematics
  • Duplicate prevention: Tracks posted files to avoid reposts
  • Rate limiting: Respectful posting intervals

Bot Commands

# Monitor Downloads folder and post new screenshots
python mastodon_bot.py

# Post existing unposted screenshots and exit
python mastodon_bot.py --scan-only

# Use different Mastodon server
python mastodon_bot.py --server your.mastodon.server

# Monitor different directory
python mastodon_bot.py --downloads ~/Pictures

Run as Background Service

# Copy service file
cp mandelbrot-bot.service ~/.config/systemd/user/

# Enable and start service
systemctl --user enable mandelbrot-bot.service
systemctl --user start mandelbrot-bot.service

# Check status
systemctl --user status mandelbrot-bot.service

File Structure

fractalus/
├── index.html                  # Main HTML interface
├── mandelbrot-renderer.js      # WebGL renderer with Mastodon integration
├── mastodon_bot.py            # File monitoring Mastodon bot
├── web_api.py                 # Web API for direct publishing
├── setup.sh                   # Setup script for bot dependencies
├── start_all.sh               # Start all services at once
├── mandelbrot-bot.service     # Systemd service file
└── README.md                  # This documentation

Screenshot Output

SVG files are named with timestamps: mandelbrot-YYYY-MM-DDTHH-MM-SS-sssZ.svg

Each SVG includes:

  • Scalable vector graphics format
  • Embedded metadata and generation timestamp
  • Optimized rect elements for efficient rendering
  • Full resolution preservation

Enjoy exploring the infinite complexity of the Mandelbrot set!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors