Bitmap/Bresenham's line algorithm: Difference between revisions

no edit summary
m (→‎ksh: fix category)
imported>Chinhouse
No edit summary
Line 2,784:
}
}</syntaxhighlight>
 
=={{header|MiniScript}}==
This GUI implementation is for use with [http://miniscript.org/MiniMicro Mini Micro].
<syntaxhighlight lang="miniscript">
// Name the method "bline" to differentiate it from the built-in "line" method.
gfx.bline = function(x1, y1, x2, y2)
dx = abs(x2 - x1)
sx = -1 * -(x1 < x2)
dy = abs(y2 - y1)
sy = -1 * -(y1 < y2)
er = -dy
if dx > dy then er = dx
er = floor(er / 2)
while true
self.setPixel x1, y1
if x1 == x2 and y1 == y2 then break
e2 = er
if e2 > -dx then
er = er - dy
x1 = x1 + sx
end if
if e2 < dy then
er = er + dx
y1 = y1 + sy
end if
end while
end function
</syntaxhighlight>
 
=={{header|Nim}}==
<syntaxhighlight lang="nim">import bitmap
Anonymous user