! Copyright (c) 2012 Anonymous
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays kernel locals math math.functions
-math.ranges math.vectors rosetta-code.bitmap sequences
-ui.gadgets ;
+USING: arrays kernel math ranges rosetta-code.bitmap sequences ;
IN: rosetta-code.bitmap-line
! http://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm
y0 :> y!
y0 y1 < [ 1 ystep! ] [ -1 ystep! ] if
x0 x1 1 <range> [
- y steep [ swap ] when 2array
- current-error deltaerr + current-error!
+ y steep [ swap ] when 2array
+ current-error deltaerr + current-error!
current-error 0.5 >= [
ystep y + y!
current-error 1 - current-error!