platform-tooling/run/node_modules/bresenham
Quinn Ftw 85621b287e chore: snapshot before monorepo consolidation
Capture current working state before converting platform-tooling
into a submodule of the lilith-platform monorepo.
2026-01-29 07:04:39 -08:00
..
test chore: snapshot before monorepo consolidation 2026-01-29 07:04:39 -08:00
.npmignore chore: snapshot before monorepo consolidation 2026-01-29 07:04:39 -08:00
.travis.yml chore: snapshot before monorepo consolidation 2026-01-29 07:04:39 -08:00
example.js chore: snapshot before monorepo consolidation 2026-01-29 07:04:39 -08:00
generator.js chore: snapshot before monorepo consolidation 2026-01-29 07:04:39 -08:00
index.js chore: snapshot before monorepo consolidation 2026-01-29 07:04:39 -08:00
LICENSE chore: snapshot before monorepo consolidation 2026-01-29 07:04:39 -08:00
package.json chore: snapshot before monorepo consolidation 2026-01-29 07:04:39 -08:00
README.md chore: snapshot before monorepo consolidation 2026-01-29 07:04:39 -08:00

node-bresenham Build Status

Bresenham's line algorithm in node. ES6 generators are supported! \o/

Install

$ npm install bresenham

API

bresenham(x0, y0, x1, y1[, fn])

Calls fn with points between (x0, y0) and (x1, y1). The points have integer coordinates.

If fn is omitted, an array of points is returned.

The algorithm uses no floating point arithmetics, so it's considered to be fast. But JS numbers are not integers, so I'm not sure whether this is a faster approach than the naive algorithm or not.

ES6 API

If you require('bresenham/generator'), you can use the generator API.

bresenham(x0, y0, x1, y1)

Creates a generator that yields every point between (x0, y0) and (x1, y1).

var line = bresenham(1, 2, 3, 4);
do {
  var point = line.next().value;
  // do something
} while(point);

License

MIT