Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bresenham

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bresenham

Bresenham's line algorithm

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
91K
increased by6.29%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 14 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc