Skip to content

About

Javascript class to find the optimum placement of a label inside an irregular polygon using Poles of Inaccessibility algorithm. Handy if you're working with maps.

Resources

Stars

0 stars

Watchers

1 watching

Forks

 
 

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

LabelPoint

Javascript class to find the optimum placement of a label inside an irregular polygon using Poles of Inaccessibility algorithm. Handy if you're working with maps.

How It Works

The Poles of Inaccessibility algorithm works by finding a point inside the polygon that is furthest from the perimeter.

Usage

Just pass in an array of points and a desired precision (defaults to 1 - pixel perfect. Increase for speed at reduced accuracy)

var points = [ {x:0, y:0}, {x:5, y:0}, {x:5, y:5}, {x:0, y:5} ];
var holes [[{}, {}, {}], ... ]; // example only
var precision = 1;
var labelPoint = LabelPoint.find(points, holes, precision);
console.log(labelPoint.x, labelPoint.y);

Originally created for Ticketlights' seating map editor. Great partner for the excellent hull.js from https://github.com/AndriiHeonia/hull

George Gardiner @ http://www.commonmode.co.uk

About

Javascript class to find the optimum placement of a label inside an irregular polygon using Poles of Inaccessibility algorithm. Handy if you're working with maps.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages