How fogleman/primitive works
Primitive Pictures is a Go image-reconstruction tool: the CLI loads and scales a target, then repeatedly searches for a shape that improves the image and writes raster, vector, or animated output. Its optimization uses parallel workers, shape mutation, and pixel-difference scoring. A Python bot also generates pictures from Flickr photos and processes tweeted images before posting results to Twitter. The core CLI and worker flow are visible in excerpts; some additional shape modes and bot polling details are documented or indexed but not fully sampled.
Main entry points: main.go CLI orchestration · main.py Bot orchestration · worker.go Search workers · model.go Image model
Components 15
CLI workflow
- CLI orchestration
main.go - Image I/O
primitive/util.go
Shape search
- Image model
primitive/model.go - Search workers
primitive/worker.go - Candidate state
primitive/state.go - Hill climbing
primitive/optimize.go - Shape generators
primitive
Raster and output
- Pixel scoring
primitive/core.go - Scanline rasterization
primitive/raster.go - Canvas rendering
primitive/model.go
Social bot
- Bot orchestration
bot/main.py
Other components
- CLI user
- Flickr service
- Twitter service
- Generated image
Connections 19
- CLI user → CLI orchestration: supplies options
README.md - CLI orchestration → Image I/O: loads input
main.go - CLI orchestration → Image model: creates and steps
main.go - Image model → Search workers: runs searches
primitive/model.go - Search workers → Candidate state: creates candidates
primitive/worker.go - Search workers → Hill climbing: hill climbs
primitive/worker.go - Search workers → Shape generators: generates shapes
primitive/worker.go - Search workers → Pixel scoring: scores candidates
primitive/worker.go - Image model → Pixel scoring: scores additions
primitive/model.go - Shape generators → Scanline rasterization: rasterizes shapes
- Image model → Canvas rendering: renders frames
primitive/model.go - CLI orchestration → Image I/O: encodes output
main.go - CLI orchestration → Generated image: writes images
main.go - Bot orchestration → Flickr service: fetches photos
bot/main.py - Bot orchestration → CLI orchestration: runs CLI
bot/main.py - Bot orchestration → Twitter service: posts results
bot/main.py - Bot orchestration → Generated image: checks generated file
bot/main.py - Flickr service → Bot orchestration: returns photos
bot/main.py - Twitter service → Bot orchestration: delivers mentions