Skip to content

malvarezcastillo/txt2plotter

Repository files navigation

txt2plotter

Convert text prompts to pen-plotter-ready SVG files using AI image generation and centerline vectorization.

Pipeline

  1. Prompt Enhancement - LLM rewrites your prompt for optimal line art generation
  2. Raster Generation - Flux.2-dev generates a high-contrast line art image
  3. Vectorization - Skeletonization and graph extraction produce clean paths
  4. Optimization - Paths are merged, simplified, and sorted for efficient plotting
  5. Output - Plotter-ready SVG with configurable dimensions

Examples

fox cat hummingbird

jellyfish monstera coffee cup

mountain waves leaf

Plotted

plotter overview cat closeup

Requirements

Installation

git clone https://github.com/malvarezcastillo/txt2plotter.git
cd txt2plotter

# Create virtual environment
python3.10 -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -e .

# Configure API keys
cp .env.example .env
# Edit .env with your keys

Usage

# Basic usage (A3 size)
python main.py "a geometric skull"

# Custom dimensions (A4)
python main.py "circuit board pattern" --width 297 --height 210

# Generate multiple variations
python main.py "mountain landscape" -n 5

# Reproducible generation with seed
python main.py "geometric pattern" --seed 42

# Generate 3 reproducible variations (uses seed, seed+1, seed+2)
python main.py "geometric pattern" -n 3 --seed 42

# Skip prompt enhancement
python main.py "minimalistic line drawing of a cat" --skip-enhance

# Batch mode: process multiple prompts from file
python main.py --batch prompts.txt -n 10

Batch File Format

Create a prompts.txt file (one prompt per line, supports comments):

# My prompts
"Minimalistic isometric impossible cube, thick black lines, technical drawing."
"Single continuous line drawing of a greyhound, Picasso style."

# This is also valid (no quotes)
A geometric skull with clean vector lines

Output is organized by prompt: output/<prompt_slug>/

Output

  • output/*.svg - Final plotter-ready SVGs
  • output/debug/ - Intermediate files for debugging:
    • 01_prompt_enhanced.txt - Enhanced prompt
    • 02_raster_raw.png - Generated image
    • 02_raster_binary.png - Thresholded binary
    • 03_skeleton.png - Skeletonized paths
    • 03_graph_*.png - Graph visualization
    • 03_paths.svg - Raw paths
    • 04_optimized.svg - After optimization

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages