C0d1ng4fun

Polygon Editor

2012-2013

An XY-symmetrical polygon with several smaller polygons in it.
An X-symmetrical polygon.
The popup menu containing all available actions.
Union of two overlapping polygons.
Triangulation of a polygon.
Landscape of connected polygons.
Home icon with polygon orientation displayed.

In late 2012 I found myself in a situation where several of my other projects were in dire need of simple user input in the form of 2D region data. Over the years I have continued to add features as I have needed them. Some of the applications are

  • 2D polygons as vector graphics, e.g. icons.
  • 2D polygons as a basis for 3D mesh generation.
  • Selection of arbitrary regions of 2D images for markup and peg puzzle generation.

The build tool, for Duke Nukem 3D, which I spent a lot of time with back in the days, was an inspiration for the user interface. It is simple and is mostly operated with keyboard interactions.

Some features of the polygon editor are:

  • Creation and editing of polygons
  • Movement and handling of polygons and edges as objects
  • Join polygons through computational geometry (union, intersection, subtraction)
  • Polygon triangulation
  • Symmetrical polygons around X, Y or both
  • Mapping of polygon coordinates to background image coordinates
  • Flexible import/export functionality, not restrainted to specific formats

Since the output from the editor need to be used in several different applications some flexible export functionality is required. My choise for the native format was XML to make it extendable. In order to make exportation simple yet flexible; I decided to implement the export functionality by applying XML transformations. There are a number of built in XSLTs to export polygons as simple comma separated lists or as Python code preserving relations between vertices. New XSLTs can be provided externally on a need to need basis.

The import module works by trying to identify different kinds of separators in textual polygon data and use it to extract points.

PolygonEditor.jar (127.4 kB)-The polygon editor.