line-offset

intelligent line offset

npm install line-offset
1 downloads in the last week
4 downloads in the last month

line-offset

Intelligently offset lines. Useful for a variety of problems, mainly map symbology, label placement, and drawing.

example

var line = [
    { x: 0, y: 10 },
    { x: 0, y: 20 },
    { x: 10, y: 20 },
    { x: 10, y: 27 }
];

var offsetLine = offset.offset(line, 10);

API

offset.offset(line, offset)

Offset a line by a certain distance. By default, expects points on the line to be in { x: 0, y: 0 } form. Offset is a required parameter and must be numeric.

Cheers

Mostly a port of includes/mapnik/offset_converter.hpp from the Mapnik project, though unlike it, a sync interface rather than a stream.

npm loves you