Skip to content

ryugen-io/svgheadergen

Repository files navigation

SVG Header Generator

SVG header generator built in Mojo that converts ASCII art into SVG graphics with customizable gradient fills.

Features

  • Written in Mojo for performance
  • Built-in color gradient presets
  • Works with figlet/toilet fonts
  • Two rendering modes: pixel mode and text mode
  • Standalone binary when compiled
  • Includes Python implementation for compatibility

Installation

Prerequisites

  • Mojo (for Mojo implementation)
  • Pixi (for dependency management)
  • figlet and/or toilet (for ASCII art rendering)
# Install figlet/toilet on most Linux distros
sudo pacman -S figlet toilet  # Arch
sudo apt install figlet toilet  # Debian/Ubuntu

Setup

# Clone the repository
git clone [email protected]:ryugen-io/svgheadergen.git
cd svgheadergen

# Install dependencies with pixi
pixi install

# Build the binary (optional)
just build
# or: mojo build svg_gen.mojo -o svg_gen

Usage

Basic Usage

# Using Mojo directly
mojo svg_gen.mojo "Hello World"

# Using compiled binary
./svg_gen "Hello World"

# Using Python fallback
python3 svg_gen.py "Hello World"

With Options

# Specify output file and font
mojo svg_gen.mojo "Hello" -o header.svg -f banner3

# Use text mode with custom gradient
mojo svg_gen.mojo "World" -f future -t -g cyber_cyan

# Custom scale
mojo svg_gen.mojo "Test" -s 15

Using Just

# Run with justfile shortcuts
just run "My Text"
just pixel "Hello" -f big
just text "Future" -g sunset

# Build and benchmark
just build
just benchmark

Rendering Modes

Pixel Mode (Default)

Converts ASCII art characters to SVG path rectangles. Best for fonts using simple characters like #:

  • banner3
  • big
  • standard
mojo svg_gen.mojo "Hello" -f banner3

Text Mode

Uses toilet's native SVG export. Best for fonts using Unicode box-drawing characters:

  • future
  • pagga
mojo svg_gen.mojo "Hello" -f future -t

Command Line Options

Usage: svg_gen.mojo [TEXT] [OPTIONS]

Arguments:
  TEXT              The text to render

Options:
  -o, --output      Output SVG file path (default: stdout)
  -f, --font        Figlet/toilet font name (default: banner3)
  -s, --scale       Scale factor for pixel mode (default: 10)
  -g, --gradient    Gradient preset name
  -t, --text-mode   Use text mode instead of pixel mode
  -h, --help        Show this help message

Performance

Run benchmarks to compare Mojo and Python implementations:

just benchmark

Development

# Format code
just fmt

# Run static checks
just check

# Clean build artifacts
just clean

Project Structure

.
├── svg_gen.mojo           # Main Mojo implementation
├── svg_gen.py             # Python fallback implementation
├── plot_benchmark.mojo    # Benchmarking utilities
├── justfile               # Task automation
├── pixi.toml              # Pixi environment config
└── README.md              # This file

License

MIT

Contributing

Contributions welcome! Please feel free to submit a Pull Request.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •