geometrize-haxe 1.0.0

A tool for recreating images with geometric primitives

Released 2017-04-17.

To install, run:

haxelib install geometrize-haxe 1.0.0

See using Haxelib in Haxelib documentation for more information.

Current version1.0.0
StatisticsInstalled 4 times
Tags cross, haxe, tool, utility

Project logo

Geometrize Haxe is a Haxe library for recreating images with geometric primitives. Run the web demo in your browser.

The Geometrize Haxe haxelib is based on the primitive Go library.

Geometrized Cat


  • Recreate images as shapes - combinations of rectangles, rotated rectangles, triangles, circles, ellipses, rotated ellipses and lines are supported.
  • Easily export geometrized images to SVG, or generated shape data to JSON.
  • All Haxe targets are supported.


Get the Haxe library from GitHub or through haxelib.

Include it in your project `.hxml`

-lib geometrize-haxe

Or add it to your `Project.xml`:

<haxelib name="geometrize-haxe" />


Refer to the Geometrize Haxe web demo and code, and this HaxeFlixel example and code. Also read the library documentation.

Basic usage: instantiate an `ImageRunner, pass it a Bitmap and starting background Rgba color. Add shapes by repeatedly calling runner.step(options), passing your ImageRunnerOptions. Export the results using the export methods of SvgExporter and ShapeJsonExporter`.

How It Works

A user provides a target image, and the algorithm finds good shapes to approximate that image. To find a good shape, the algorithm generates a large number of random candidate shapes, repeatedly improving the fit of each using a hillclimbing optimization approach, eventually choosing the best fitting shape. Shapes are added one by one.

A detailed explanation of how the algorithm works is given in the primitive readme.


Examples And Screenshots

There is no jagginess when saving images as vector-based SVG e.g. pyramid or pomegranate.

Examples from geometrizing public domain artwork and photos:

Geometrized Swan Geometrized Peacock Geometrized Leafy Railroad Geometrized Road Geometrized Sunflower Geometrized Woodland Cemetery Geometrized Figs Geometrized Pomegranate Geometrized Monarch Butterfly Geometrized Gustave Courbet Geometrized Fairies Geometrized Pyramid Geometrized Chomsky


  • This implementation is single-threaded, and performance varies by target platform. Small target images are recommended - you probably do not need the detail anyway.
  • Got an idea or suggestion? Open an issue on GitHub, or send Sam a message on Twitter.
  • Geometrize Haxe is based on primitive, a Go library created by Michael Fogleman.
  • Geometrize Haxe is available as a haxelib.
  • All Haxe targets are supported.