Git Product home page Git Product logo

geometrize-haxe's Introduction

Project logo

Haxelib Version Travis Unit Test Build Status Code Climate License

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

Features

  • 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.

Install

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" />

Usage

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.

Resources

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

Notes

  • 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.
  • Geometrize Haxe has unit tests.
  • All Haxe targets are supported.

geometrize-haxe's People

Contributors

tw1ddle avatar

Watchers

Erdem Orman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.