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 if (y0<y1) sy=1
local done=false,err local done=false,err
local queue={}
if dx>dy then if dx>dy then
err=dx/2.0 err=dx/2.0
return function() return function()
if (queue==nil) return if (done) return
if (x==x1) queue=nil return x1,y1 if (x==x1) done=true return x1,y1
if #queue==0 then local oldx,oldy=x,y
add(queue,{x,y}) err-=dy
err-=dy if (err<0) y+=sy err+=dx
if (err<0) y+=sy add(queue,{x,y}) err+=dx x+=sx
x+=sx return oldx,oldy
end
return unpack(deli(queue,1))
end end
else else
err=dy/2.0 err=dy/2.0
return function() return function()
if (queue==nil) return if (done) return
if (y==y1) queue=nil return x1,y1 if (y==y1) done=true return x1,y1
if #queue==0 then local oldx,oldy=x,y
add(queue,{x,y}) err-=dx
if (err<0) x+=sx err+=dy
local oldx,oldy=x,y y+=sy
err-=dx return oldx,oldy
if (err<0) x+=sx add(queue,{x,y}) err+=dy
y+=sy
end
return unpack(deli(queue,1))
end end
end end
end end