This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Bresenhams line algorithm for integers. | |
* @see https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm#Algorithm_for_integer_arithmetic | |
*/ | |
function plotLine(x0, y0, x1, y1) { | |
/** Step direction on the x-axis */ | |
let sx = x0 < x1 ? 1 : -1 | |
/** Step direction on the y-axis */ | |
let sy = y0 < y1 ? 1 : -1 |