Tw1ddle / geometrize-haxe

:triangular_ruler: Geometrize is a Haxe port of primitive that geometrizes images into geometric primitives
https://www.geometrize.co.uk/
Other
348 stars 31 forks source link
art geometrize geometry-processing haxe haxelib hill-climbing primitives

Project logo

License Build Status Badge Haxelib Version

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

Geometrize Haxe is part of Geometrize and was inspired by the primitive Go library.

Geometrized Cat 500 Triangles

Features

Shape Comparison

The matrix shows typical results for circles, triangles, rotated rectangles, rotated ellipses and all supported shapes at 50, 200 and 500 total shapes:

- 50 Shapes 200 Shapes 500 Shapes
Circles 50 Circles 200 Circles 500 Circles
Triangles 50 Triangles 200 Triangles 500 Triangles
Rotated Rectangles 50 Rotated Rectangles 200 Rotated Rectangles 500 Rotated Rectangles
Rotated Ellipses 50 Rotated Ellipses 200 Rotated Ellipses 500 Rotated Ellipses
All Shapes 50 All Shapes 200 All Shapes 500 All Shapes

How It Works

A user provides a target image, and the algorithm finds shapes to approximate that image. To identify 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. The shapes are added one by one.

JavaScript Usage

If you are working in JavaScript, check out geometrizejs which provides JavaScript API and types for this library, tested on browser and Node.js.

On top of it, geometrizejs-cli tool provides command line interface and support for common image formats.

Haxe Install

Get the Haxe library from GitHub or through haxelib:

haxelib install geometrize-haxe

Haxe Usage

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

Resources

Examples And Screenshots

Geometrized public domain artwork and photos:

Geometrized Flower 330 Rotated Ellipses Geometrized Train 230 Rotated Ellipses Geometrized Woodland Cemetery 600 Rotated Rectangles Geometrized Pomegranate 300 Rotated Ellipses Geometrized Monarch Butterfly 800 Various Shapes Geometrized Leafy Railroad 800 Rotated Rectangles Geometrized Pyramid 150 Triangles Geometrized Trees 210 Ellipses Geometrized Chomsky 300 Triangles Geometrized Trees 250 Rotated Ellipses Geometrized Fairies 500 Triangles

For more examples, see the Geometrize gallery.

Notes