# fogleman/primitive

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/fogleman-primitive).**

13,158 stars · 647 forks · Go · MIT

## Links

- GitHub: https://github.com/fogleman/primitive
- Homepage: https://primitive.lol/
- awesome-repositories: https://awesome-repositories.com/repository/fogleman-primitive.md

## Topics

`art` `go` `graphics` `primitives`

## Description

Primitive is an algorithmic art generator and geometric image reconstruction tool that transforms raster images into stylized vector compositions. It functions as an iterative shape optimizer and raster-to-vector converter, approximating pixel-based photos by layering geometric primitives such as triangles, circles, and rectangles.

The project utilizes a search algorithm to determine the optimal position, size, and color for each shape to minimize the visual difference from the source image. Users can apply shape constraint definitions to control the properties and orientations of the geometric primitives to achieve specific artistic effects.

The system supports the generation of iterative reconstruction states, allowing the process to be exported as raster images, vector graphics, or animated frame sequences.

## Tags

### Artificial Intelligence & ML

- [Procedural Art Generators](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/prompt-engineering-libraries/creative-content-generation/generative-art-prompts/procedural-art-generators.md) — Generates stylized art by using search algorithms to optimize the placement of basic geometric shapes.

### Part of an Awesome List

- [Image Synthesis](https://awesome-repositories.com/f/awesome-lists/ai/image-synthesis.md) — Iteratively synthesizes a visual representation by adding shapes one at a time to reconstruct an image.

### Graphics & Multimedia

- [Geometric Image Reconstruction](https://awesome-repositories.com/f/graphics-multimedia/geometric-image-reconstruction.md) — Approximates raster images by iteratively layering geometric primitives like triangles and circles.
- [Image Processing](https://awesome-repositories.com/f/graphics-multimedia/image-editing-processing/image-processing.md) — Processes input raster images by layering geometric primitives to reproduce the original visual. ([source](https://github.com/fogleman/primitive#readme))
- [Raster-to-Vector Conversions](https://awesome-repositories.com/f/graphics-multimedia/raster-to-vector-conversions.md) — Translates raster pixel data into a composition of geometric vector primitives.
- [Vector Art Approximation](https://awesome-repositories.com/f/graphics-multimedia/vector-art-approximation.md) — Transforms pixel-based images into simplified vector compositions using triangles, circles, and rectangles.
- [Coordinate-Based Search](https://awesome-repositories.com/f/graphics-multimedia/coordinate-based-search.md) — Implements a coordinate-based search to determine the optimal position and scale for geometric primitives.
- [Multi-Format Output Renderers](https://awesome-repositories.com/f/graphics-multimedia/graphics-engines-rendering/rendering/systems/multi-format-output-renderers.md) — Provides a rendering system that can export the internal shape representation to both raster and vector formats.

### Scientific & Mathematical Computing

- [Iterative Error Minimization](https://awesome-repositories.com/f/scientific-mathematical-computing/iterative-error-minimization.md) — Calculates the visual difference between the target image and current state to guide shape placement.
- [Greedy](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/algorithms-and-complexity/algorithms/greedy.md) — Employs a greedy algorithm to place shapes one by one based on the best local fit.
- [Shape Placement Optimization](https://awesome-repositories.com/f/scientific-mathematical-computing/shape-placement-optimization.md) — Optimizes the position, size, and color of shapes to minimize the visual difference from a source image.

### Software Engineering & Architecture

- [VNode Shape Optimizations](https://awesome-repositories.com/f/software-engineering-architecture/diffing-algorithms/vnode-shape-optimizations.md) — Implements an iterative search algorithm to optimize the placement and color of primitives against a target image. ([source](https://github.com/fogleman/primitive#readme))
- [Constraint Definitions](https://awesome-repositories.com/f/software-engineering-architecture/object-oriented-models/graphics-primitives/geometric-primitives/constraint-definitions.md) — Provides a system for constraining geometric properties to achieve specific artistic effects. ([source](https://github.com/fogleman/primitive/blob/master/README.md))

### User Interface & Experience

- [Geometric Shape Stacking](https://awesome-repositories.com/f/user-interface-experience/canvas-workspace-management/layered-canvas-composition/geometric-shape-stacking.md) — Builds images by stacking semi-transparent or opaque primitives to approximate visual density.
