Anonymous user
Bitmap/Bresenham's line algorithm: Difference between revisions
Bitmap/Bresenham's line algorithm (view source)
Revision as of 17:41, 9 November 2023
, 6 months ago→{{header|MiniScript}}
imported>Chinhouse |
imported>Chinhouse |
||
(3 intermediate revisions by the same user not shown) | |||
Line 2,836:
This GUI implementation is for use with [http://miniscript.org/MiniMicro Mini Micro].
<syntaxhighlight lang="miniscript">
drawLine = function(img, x0, y0, x1, y1, colr)
dx = abs(x2 - x1)▼
return -1
end function
dy = abs(y2 - y1)▼
sx = sign(x0, x1)
▲ if dx > dy then er = dx
er = floor(er / 2)▼
if dx > dy then
err = dx
else
err = -dy
end if
while true
if
e2 =
if e2 > -dx then
end if
if e2 < dy then
end if
end while
end function
img= Image.create(320, 320)
drawLine img, 0, 0, 250, 300, color.red
gfx.clear
gfx.drawImage img, 0, 0
</syntaxhighlight>
|