Skip to content

izag8216/tilegen

Repository files navigation

tilegen

Seamless pattern & tile generator CLI
Create mathematical, geometric, and organic seamless tiles — offline, from your terminal.

License Python Status

English | 日本語


Features

  • 10 pattern algorithms — hexagon, waves, diamond, triangles, circles, squares, noise, chevron, dots, maze
  • 10 color presets — warm, cool, earth, neon, pastel, mono, sunset, ocean, forest, retro
  • PNG & SVG output — vector or raster, your choice
  • CSS data URI export — inline tiles directly in stylesheets
  • Terminal preview — ASCII art preview without generating files
  • Fully offline — no API keys, no internet, no SaaS
  • Deterministic — seed-based reproducibility

Installation

pip install tilegen

Or from source:

git clone https://github.com/izag8216/tilegen.git
cd tilegen
pip install -e .

Quick Start

# Generate a hexagonal pattern
tilegen generate --type hexagon --preset ocean --size 200

# Generate waves with custom colors
tilegen generate --type waves --colors "#2D5A27,#3A6B8C,#E67E22" --output tile.svg

# Create CSS data URI from a tile image
tilegen css --input tile_hexagon_200.png --output background.css

# Preview in terminal
tilegen preview --type noise --preset neon

# List all patterns and presets
tilegen list

Pattern Types

Pattern Description
hexagon Hexagonal tessellation with edge lines
waves Sinusoidal wave bands
diamond Diamond/rhombus tessellation
triangles Triangular tessellation grid
circles Overlapping circles (truchet-like)
squares Checkerboard with inset moroccan tiles
noise Organic value-noise with octave layering
chevron Chevron/herringbone stripe pattern
dots Polka dots with offset rows
maze Truchet maze tile arcs

Color Presets

Preset Colors
warm Orange, Gold, Red tones
cool Green, Blue, Teal tones
earth Brown, Olive, Tan tones
neon Pink, Purple, Electric Blue
pastel Soft pink, green, blue, yellow
mono Dark navy, Deep blue, Purple
sunset Red, Coral, Gold, Crimson
ocean Deep blue, Cyan, Turquoise
forest Forest green, Olive, Sage
retro Yellow, Orange, Teal, Purple

Use custom colors with --colors "#FF0000,#00FF00,#0000FF".

CLI Reference

tilegen generate

Generate a seamless pattern tile.

tilegen generate --type <pattern> [--colors <hex,...>] [--preset <name>] [--size N] [--output FILE] [--seed N]
Option Default Description
--type required Pattern algorithm
--colors preset Comma-separated hex colors
--preset cool Color preset name
--size 200 Tile size in pixels
--output, -o auto Output file (.png or .svg)
--seed 42 Random seed

tilegen css

Convert a tile image to CSS with base64 data URI.

tilegen css --input <image> [--output FILE] [--class-name NAME]

tilegen list

List available patterns and color presets.

tilegen preview

Preview a pattern as ASCII art in the terminal.

tilegen preview --type <pattern> [--colors <hex,...>] [--preset <name>] [--width N]

Usage Examples

Generate tiles for web backgrounds

# SVG tile for a landing page
tilegen generate --type hexagon --preset cool --size 120 --output bg.svg

# Convert to CSS
tilegen css --input bg.svg --output background.css --class-name hero-bg

Batch generate different patterns

for type in hexagon waves diamond noise; do
  tilegen generate --type $type --preset forest --size 300 --output ${type}_tile.png
done

Create a custom-colored tile

tilegen generate --type maze --colors "#1a1a2e,#e94560,#16213e" --size 256 --output maze_dark.png

Architecture

src/tilegen/
  __init__.py           Version
  cli.py                Click CLI (generate, css, list, preview)
  presets.py             Color presets & resolution
  patterns/
    __init__.py          Pattern registry
    base.py              Abstract base class
    hexagon.py           Hexagonal tessellation
    waves.py             Sinusoidal waves
    diamond.py           Diamond tessellation
    triangles.py         Triangular tessellation
    circles.py           Overlapping circles
    squares.py           Checkerboard tiles
    noise.py             Value noise (4-octave)
    chevron.py           Chevron stripes
    dots.py              Polka dots
    maze.py              Truchet maze
  renderers/
    __init__.py          Renderer exports
    png_renderer.py      PIL PNG output
    svg_renderer.py      svgwrite SVG output
    css_renderer.py      Base64 data URI CSS

Development

# Install with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=tilegen --cov-report=term-missing

License

MIT License — see LICENSE for details.

Contributing

See CONTRIBUTING.md for guidelines.


Made with Python + math
No design skills required.

About

Seamless pattern & tile generator CLI -- 10 algorithms, 10 presets, PNG/SVG/CSS output, fully offline

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors