Skip to content

Instantly share code, notes, and snippets.

View garymcm's full-sized avatar

Gary McMeekin garymcm

  • Rocky Pond Consulting, Inc.
  • Massachussets
View GitHub Profile
/**
* 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