Bitmap/Bresenham's line algorithm: Difference between revisions

Content added Content deleted
m (Added export mark fro "drawLine".)
(Changed "pixel" to "color" and "Pixel" to "Color" to match "bitmap.nim" interface.)
Line 2,624: Line 2,624:
<lang nim>import bitmap
<lang nim>import bitmap


proc drawLine*(img: var Image; p, q: Point; pixel: Pixel) =
proc drawLine*(img: var Image; p, q: Point; color: Color) =
let
let
dx = abs(q.x - p.x)
dx = abs(q.x - p.x)
Line 2,638: Line 2,638:


while true:
while true:
img[p.x, p.y] = pixel
img[p.x, p.y] = color
if p == q:
if p == q:
break
break