Jump to content

Bitmap/Bresenham's line algorithm: Difference between revisions

imported>Chinhouse
imported>Chinhouse
Line 2,846:
return j
end function
Img.line = function(x0, y0, x1, y1, colr)
Img.pixelColor = color.white
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, self.pixelColorcolr
if x0 == x1 and y0 == y1 then break
e2 = err
Line 2,879 ⟶ 2,878:
end if
end while
self.setPixel x0, y0, self.pixelColorcolr
end function
 
img= Img.create(320, 320)
img.line 0,0, 250, 300, color.red
gfx.clear
gfx.drawImage img, 0, 0
 
</syntaxhighlight>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.