main #12

Merged
kistaro merged 20 commits from pyrex/chameleonic:main into main 2022-12-23 06:38:45 +00:00
Showing only changes of commit 1be4846698 - Show all commits

View File

@ -103,13 +103,14 @@ end
function _rast( function _rast(
x0,y0,x1,y1 xs,ys,x0,y0,x1,y1
) )
local dx=abs(x1-x0) local function _add()
local dy=abs(y1-y0) local n=#xs
local x=x0 if (n==0 or xs[n]!=x0 or ys[n]!=y0) add(xs,x0) add(ys,y0)
local y=y0 end
local dx,dy=abs(x1-x0),abs(y1-y0)
local sx=-1 local sx=-1
local sy=-1 local sy=-1
if (x0<x1) sx=1 if (x0<x1) sx=1
@ -118,27 +119,22 @@ function _rast(
local done=false,err local done=false,err
if dx>dy then if dx>dy then
err=dx/2.0 err=dx/2.0
return function() while x0!=x1 do
if (done) return _add()
if (x==x1) done=true return x1,y1
local oldx,oldy=x,y
err-=dy err-=dy
if (err<0) y+=sy err+=dx if (err<0) y0+=sy err+=dx
x+=sx x0+=sx
return oldx,oldy
end end
else else
err=dy/2.0 err=dy/2.0
return function() while y0!=y1 do
if (done) return _add()
if (y==y1) done=true return x1,y1
local oldx,oldy=x,y
err-=dx err-=dx
if (err<0) x+=sx err+=dy if (err<0) x0+=sx err+=dy
y+=sy y0+=sy
return oldx,oldy
end end
end end
_add()
end end
-->8 -->8
@ -1199,12 +1195,7 @@ function rope:_check_sane()
local n1=n0.next local n1=n0.next
if (n1==nil) break if (n1==nil) break
for qx,qy in _rast(flr(n0.ax*2),flr(n0.ay*2),flr(n1.ax*2),flr(n1.ay*2)) do _rast(qxs,qys,flr(n0.ax*2),flr(n0.ay*2),flr(n1.ax*2),flr(n1.ay*2))
if not (qx==qxs[#qxs] and qy==qys[#qys]) then
add(qxs,qx)
add(qys,qy)
end
end
n0=n1 n0=n1
end end