forked from pyrex/chameleonic
My fat bresenham implementation is really slow
This commit is contained in:
parent
a20ad44f75
commit
13e6c382be
@ -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})
|
||||
if (done) return
|
||||
if (x==x1) done=true return x1,y1
|
||||
local oldx,oldy=x,y
|
||||
err-=dy
|
||||
if (err<0) y+=sy add(queue,{x,y}) err+=dx
|
||||
if (err<0) y+=sy err+=dx
|
||||
x+=sx
|
||||
end
|
||||
return unpack(deli(queue,1))
|
||||
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})
|
||||
|
||||
if (done) return
|
||||
if (y==y1) done=true return x1,y1
|
||||
local oldx,oldy=x,y
|
||||
err-=dx
|
||||
if (err<0) x+=sx add(queue,{x,y}) err+=dy
|
||||
if (err<0) x+=sx err+=dy
|
||||
y+=sy
|
||||
end
|
||||
return unpack(deli(queue,1))
|
||||
return oldx,oldy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user