Bitmap/Bresenham's line algorithm: Difference between revisions
Content deleted Content added
imported>Chinhouse |
imported>Chinhouse |
||
Line 2,846: | Line 2,846: | ||
return j |
return j |
||
end function |
end function |
||
⚫ | |||
Img.pixelColor = color.white |
|||
⚫ | |||
sign = function(a, b) |
sign = function(a, b) |
||
if a < b then return 1 |
if a < b then return 1 |
||
Line 2,867: | Line 2,866: | ||
while true |
while true |
||
self.setPixel x0, y0, |
self.setPixel x0, y0, colr |
||
if x0 == x1 and y0 == y1 then break |
if x0 == x1 and y0 == y1 then break |
||
e2 = err |
e2 = err |
||
Line 2,879: | Line 2,878: | ||
end if |
end if |
||
end while |
end while |
||
self.setPixel x0, y0, |
self.setPixel x0, y0, colr |
||
end function |
end function |
||
img= Img.create(320, 320) |
img= Img.create(320, 320) |
||
img.line 0,0, 250, 300 |
img.line 0,0, 250, 300, color.red |
||
gfx.clear |
gfx.clear |
||
gfx.drawImage img, 0, 0 |
gfx.drawImage img, 0, 0 |
||
</syntaxhighlight> |
</syntaxhighlight> |
||