# doesn't handle vertical lines def (line x0 y0 x1 y1) let steep ((> abs) y1-y0 x1-x0) when steep swap! x0 y0 swap! x1 y1 when (x0 > x1) swap! x0 x1 swap! y0 y1 withs (deltax x1-x0 deltay (abs y1-y0) error deltax/2 ystep (if (y0 < y1) 1 -1) y y0) for x x0 (x <= x1) ++x if steep plot y x plot x y error -= deltay when (error < 0) y += ystep error += deltax