You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

dda-line-algorithm

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dda-line-algorithm

DDA line algorithm point generation

1.0.4
latest
Source
npm
Version published
Maintainers
1
Created
Source

typescript

DDALineDrawing

This Node.js library (support TypeScript) will facilitate the calculation of DDA algorithm for a given 2 end points.

Installation

 npm install dda-line-algorithm

Usage

DDALine method reqire 4 integers (startX, startY, endX, endY) as parameters and algorithm will generate the line coordinates between the starting and ending points and returns array of objects

To get the coordinates of line from (1,4) to (5,9) use below code

let dda = require('dda-line-algorithm') OR import dda from 'dda-line-algorithm'
let pointsList = dda.DDALine (1,4,5,9);

returns

[ { x: 1, y: 4 },
  { x: 2, y: 5 },
  { x: 3, y: 6 },
  { x: 3, y: 7 },
  { x: 4, y: 8 },
  { x: 5, y: 9 } ]

Access points

you can access points using

for(const point of pointsList) {
  x = point.x
  y = point.y
  // ...
}

Keywords

line drawing

FAQs

Package last updated on 06 Jun 2021

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