镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

About

No description, website, or topics provided.

Resources

Stars

69 stars

Watchers

4 watching

Forks

Latest commit

 

History

21 Commits

Folders and files

Repository files navigation

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).

import bresenham from 'bresenham/generator';

for (const point of bresenham(1, 2, 3, 4)) {
  // ...
}

License

MIT

About

No description, website, or topics provided.

Resources

Stars

69 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages