Bitmap/Bresenham's line algorithm: Difference between revisions
Content deleted Content added
→{{header|Wart}}: Separated Wren from Wart entry and fixed an error. |
Added "import bitmap", adding pixel parameter (color), adding example and output. |
||
Line 2,622:
=={{header|Nim}}==
<lang nim>import
proc
let
dx = abs(q.x - p.x)
Line 2,638:
while true:
img[p.x, p.y] =
if p == q:
break
Line 2,647:
if e2 < dy:
err += dx
p.y += sy
when isMainModule:
var img = initImage(16, 16)
img.fill(White)
img.drawLine((0, 7), (7, 15), Black)
img.drawLine((7, 15), (15, 7), Black)
img.drawLine((15, 7), (7, 0), Black)
img.drawLine((7, 0), (0, 7), Black)
img.print()</lang>
{{out}}
<pre>.......H........
......H.H.......
.....H...H......
....H.....H.....
...H.......HH...
..H..........H..
.H............H.
H..............H
.H............H.
..H..........H..
...H........H...
...H.......H....
....H.....H.....
.....H...H......
......H.H.......
.......H........</pre>
=={{header|OCaml}}==
|