: fline ( x1 y1 x2 y2 --- ) y2 ! x2 ! y1 ! x1 ! flag off x2 @ x1 @ - \ x2-x1 \ dup x0 ! dup 0> if 1 else -1 then xdir ! abs dup dx ! \ dx y2 @ y1 @ - \ dx y2-y1 \ dup y0 ! dup 0> if 1 else -1 then ydir ! abs dup dy ! \ dx dy x1 @ y1 @ color @ plot < if \ x2 y2 exch dx dy exch x1 y1 exch ( x0 y0 exch) xdir ydir exch flag on then dy @ 2* \ dy<<1 dup dx @ - d ! incr1 ! \ dy @ dx @ - 2* incr2 ! \ x0 @ 0> if 1 else -1 then xdir ! \ y0 @ 0> if 1 else -1 then ydir ! begin x1 @ x2 @ - while xdir @ x1 +! d @ 0< if incr1 else ydir @ y1 +! incr2 then @ d +! x1 @ y1 @ flag @ if swap then color @ plot repeat ; \ ======================================================================== : usefl ['] fline is line ;