dda-line-algorithm
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

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
  // ...
}

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i dda-line-algorithm

    Weekly Downloads

    3

    Version

    1.0.4

    License

    ISC

    Unpacked Size

    7.51 kB

    Total Files

    6

    Last publish

    Collaborators

    • ihalapathirana