# sprite_gen Procedural creature sprites for businesses. You give it a business name and logo. It picks a type, builds a creature from parts and recolors it with the logo's brand colors. There are two part libraries: | Library | Size | Art | Registry | |---|---|---|---| | `pixellab` (default) | 64x64 | Generated with [PixelLab](https://pixellab.ai), see [PixelLab library](#pixellab-library) | `sprite_parts_pl.py` + `pixellab_library/*.json` | | `classic` | 96x96 | Hand-written text grids | `sprite_parts.py` | ## Setup ```bash pip install -r requirements.txt ``` You only need an [OpenRouter](https://openrouter.ai) API key if you want the type picked automatically. Set `OPENROUTER_API_KEY` in the environment or in `.env`, or skip the key by passing `--type`. ## Generate a sprite ```bash # Type picked from the business name OPENROUTER_API_KEY= python generate_sprite.py "Rosas Landscaping" logos/rosas.png # Add a description to help pick the type OPENROUTER_API_KEY= python generate_sprite.py "Rosas Landscaping" logos/rosas.png --desc "Lawn care and garden design" # Set the type yourself (no API key needed) python generate_sprite.py "Rosas Landscaping" logos/rosas.png --type grass # Set the colors yourself instead of using a logo (main color first) python generate_sprite.py "Rosas Landscaping" --type grass --colors "#2E7D32,#FBC02D" # A different creature for the same business python generate_sprite.py "Rosas Landscaping" logos/rosas.png --type grass --reroll 1 # Both libraries side by side python generate_sprite.py "Rosas Landscaping" logos/rosas.png --type grass --compare # No logo file: find the logo on the business's website python generate_sprite.py "Rosas Landscaping" --domain rosaslandscaping.com --type grass ``` Each run writes `sprites/.png`, `sprites/@4x.png` and `sprites/.json` (library, type, parts, colors). With `--reroll N`, the file names end in `-rN`. With `--compare`, each library writes `-.*` and `-compare.png` shows them next to each other at the same height. Both use the same type and colors. | Option | Meaning | |---|---| | `--type T` | Skip the classifier. One of: normal fire water grass electric ice fighting poison ground flying psychic bug rock ghost dragon | | `--desc TEXT` | Description sent to the classifier (default: the name) | | `--colors "#main,#accent"` | Manual colors; overrides the logo | | `--reroll N` | Alternate creature; the name alone always gives the same sprite | | `--library NAME` | `pixellab` (default) or `classic` | | `--compare` | Render with both libraries and write a comparison sheet | | `--out DIR` | Output folder (default `sprites`) | | `--scale N` | Size of the upscaled copy (default 4, `1` disables it) | | `--domain D` | Find the logo on this website when no logo file or `--colors` is given (see [Logo from a domain](#logo-from-a-domain)) | | `--logo-cache DIR` | Where logos found with `--domain` are cached (default `logos`) | Logo colors: transparent pixels, soft edge pixels and a solid white/black/gray background are ignored, and colored brand colors are used before white, black or gray. A logo with only white, black or gray in it still uses those colors. ## Batch Use a CSV with the columns `name,logo,domain,type,description`. Only `name` is required. Rows with no `type` use the classifier, and rows with a `domain` but no `logo` look the logo up on that website. ```bash OPENROUTER_API_KEY= python generate_sprite.py --batch businesses.csv --out sprites ``` Add `--compare` to get both libraries for every row. ## Logo from a domain `logo_fetch.py` finds a business's logo from its website and caches it by domain. ```bash python logo_fetch.py rosaslandscaping.com --out logos # -> logos/rosaslandscaping.com.png (method) python logo_fetch.py rosaslandscaping.com --extra https://staging.example.net/ # also search this page ``` ```python from logo_fetch import fetch_logo, fetch_logo_info, normalize_domain fetch_logo("rosaslandscaping.com", "logos") # Path or None fetch_logo_info("rosaslandscaping.com", "logos", extra_urls=["https://staging.example.net/"]) # (Path or None, method) normalize_domain("HTTPS://www.Rosas.com/about") # "rosas.com" ``` Search order, best first. The first image with a brand hue wins; an image with only white/black/gray is kept as a fallback in case nothing colorful turns up (its method ends in `-mono`). | Method | Source | |---|---| | `site-logo` | The homepage (https, then http, without and with www): images with "logo" in class/id/file name/alt, images in a logo/brand container, the first image in `
`/`