Jump to content

Bitmap/Bresenham's line algorithm: Difference between revisions

m
minor tweaks to make more usable elsewhere on rc
m (minor tweaks to make more usable elsewhere on rc)
Line 2,316:
end,
get = function(self, x, y)
x, y = math.floor(x+1), math.floor(y+1)
if ((x>=1) and (x<=self.width) and (y>=1) and (y<=self.height)) then
return self.pixels[y][x]
Line 2,324:
end,
set = function(self, x, y, c)
x, y = math.floor(x+1), math.floor(y+1)
if ((x>=1) and (x<=self.width) and (y>=1) and (y<=self.height)) then
self.pixels[y][x] = c or 0x00000000
Line 2,341:
local err = math.floor((dx>dy and dx or -dy)/2)
while(true) do
self:set(x1, y1, c or 0xFFFFFFFF)
if (x1==x2 and y1==y2) then
break
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.