Geometrize Haxe Library

Geometrize Haxe is a Haxe library for recreating images with geometric primitives

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/585407/1866784/Geometrize%20Haxe%20Library.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Author
cubic074
Version
0.0.1.20260703143909
Created
2026-07-03
Updated
2026-07-03
Size
89.7 KB
License
N/A

Geometrize Haxe Library

This is a standalone browser build of the original Geometrize algorithm. It exposes itself on globalThis.geometrize and uses a bundled Web Worker to iteratively approximate a target image with simple geometric shapes.

How It Works

The script expects specific DOM elements to exist, such as runpausebutton, stepbutton, openimageinput, circles, lines, shapesaddedtext, maxshapescaptextedit, and currentsvgcontainer.

When initialized, it:

  1. Loads a target image from the file input or from geometrize.setTargetCanvas(canvas).
  2. Converts the image into an internal bitmap.
  3. Sends the bitmap to its Web Worker.
  4. On each step, the worker searches for the best next shape.
  5. The selected shape is appended to:
    • shapeJsonData
    • shapeSvgData
    • the live SVG preview in currentsvgcontainer
  6. Generation stops when the max shape count is reached or when paused.

Exposed API

The script exposes helper methods on globalThis.geometrize:

  • geometrize.main
  • geometrize.getShapeJsonData()
  • geometrize.getShapeSvgData()
  • geometrize.getShapeCount()
  • geometrize.setTargetCanvas(canvas)
  • geometrize.setMaxShapeCount(limit)