Anonymous user
Bitmap/Bresenham's line algorithm: Difference between revisions
Bitmap/Bresenham's line algorithm (view source)
Revision as of 17:02, 9 November 2023
, 6 months ago→{{header|MiniScript}}
imported>Chinhouse |
imported>Chinhouse |
||
Line 2,846:
return j
end function
Img.line = function(x0, y0, x1, y1, colr)▼
▲Img.line = function(x0, y0, x1, y1)
sign = function(a, b)
if a < b then return 1
Line 2,867 ⟶ 2,866:
while true
self.setPixel x0, y0,
if x0 == x1 and y0 == y1 then break
e2 = err
Line 2,879 ⟶ 2,878:
end if
end while
self.setPixel x0, y0,
end function
img= Img.create(320, 320)
img.line 0,0, 250, 300, color.red
gfx.clear
gfx.drawImage img, 0, 0
</syntaxhighlight>
|