My fat bresenham implementation is really slow

This commit is contained in:
Pyrex 2022-12-17 13:30:48 -08:00
parent a20ad44f75
commit 13e6c382be

View File

@ -967,34 +967,27 @@ function rope:_rast(
if (y0<y1) sy=1
local done=false,err
local queue={}
if dx>dy then
err=dx/2.0
return function()
if (queue==nil) return
if (x==x1) queue=nil return x1,y1
if #queue==0 then
add(queue,{x,y})
err-=dy
if (err<0) y+=sy add(queue,{x,y}) err+=dx
x+=sx
end
return unpack(deli(queue,1))
if (done) return
if (x==x1) done=true return x1,y1
local oldx,oldy=x,y
err-=dy
if (err<0) y+=sy err+=dx
x+=sx
return oldx,oldy
end
else
err=dy/2.0
return function()
if (queue==nil) return
if (y==y1) queue=nil return x1,y1
if #queue==0 then
add(queue,{x,y})
local oldx,oldy=x,y
err-=dx
if (err<0) x+=sx add(queue,{x,y}) err+=dy
y+=sy
end
return unpack(deli(queue,1))
if (done) return
if (y==y1) done=true return x1,y1
local oldx,oldy=x,y
err-=dx
if (err<0) x+=sx err+=dy
y+=sy
return oldx,oldy
end
end
end