forked from pyrex/chameleonic
update main #3
@ -22,7 +22,6 @@ function names(root)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function _doall(x)
|
function _doall(x)
|
||||||
|
|
||||||
for n in names(x) do
|
for n in names(x) do
|
||||||
for mod in all(modules) do
|
for mod in all(modules) do
|
||||||
local f=mod[n]
|
local f=mod[n]
|
||||||
@ -32,13 +31,12 @@ function _doall(x)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- source: https://www.lexaloffle.com/bbs/?pid=78990
|
-- source: https://www.lexaloffle.com/bbs/?pid=78990
|
||||||
gaps={57,23,10,4,1}
|
gaps=split"57,23,10,4,1"
|
||||||
--{701,301,132,57,23,10,4,1}
|
--{701,301,132,57,23,10,4,1}
|
||||||
function shellsort(a)
|
function shellsort(a)
|
||||||
for gap in all(gaps) do
|
for gap in all(gaps) do
|
||||||
for i=gap+1,#a do
|
for i=gap+1,#a do
|
||||||
local x=a[i]
|
local x,j=a[i],i-gap
|
||||||
local j=i-gap
|
|
||||||
while j>=1 and a[j].key>x.key do
|
while j>=1 and a[j].key>x.key do
|
||||||
a[j+gap]=a[j]
|
a[j+gap]=a[j]
|
||||||
j-=gap
|
j-=gap
|
||||||
@ -57,36 +55,36 @@ function linefill(ax,ay,bx,by,r,c)
|
|||||||
local n=min(abs(dx),abs(dy))/d
|
local n=min(abs(dx),abs(dy))/d
|
||||||
d*=sqrt(n*n+1)
|
d*=sqrt(n*n+1)
|
||||||
if(d<0.001) return
|
if(d<0.001) return
|
||||||
local ca,sa=dx/d,-dy/d
|
local ca,sa=dx/d,-dy/d
|
||||||
|
|
||||||
-- polygon points
|
-- polygon points
|
||||||
local s={
|
local s={
|
||||||
{0,-r},{d,-r},{d,r},{0,r}
|
{0,-r},{d,-r},{d,r},{0,r}
|
||||||
}
|
}
|
||||||
local u,v,spans=s[4][1],s[4][2],{}
|
local u,v,spans=s[4][1],s[4][2],{}
|
||||||
local x0,y0=ax+u*ca+v*sa,ay-u*sa+v*ca
|
local x0,y0=ax+u*ca+v*sa,ay-u*sa+v*ca
|
||||||
for i=1,4 do
|
for i=1,4 do
|
||||||
local u,v=s[i][1],s[i][2]
|
local u,v=s[i][1],s[i][2]
|
||||||
local x1,y1=ax+u*ca+v*sa,ay-u*sa+v*ca
|
local x1,y1=ax+u*ca+v*sa,ay-u*sa+v*ca
|
||||||
local _x1,_y1=x1,y1
|
local _x1,_y1=x1,y1
|
||||||
if(y0>y1) x0,y0,x1,y1=x1,y1,x0,y0
|
if(y0>y1) x0,y0,x1,y1=x1,y1,x0,y0
|
||||||
local dx=(x1-x0)/(y1-y0)
|
local dx=(x1-x0)/(y1-y0)
|
||||||
if(y0<0) x0-=y0*dx y0=-1
|
if(y0<0) x0-=y0*dx y0=-1
|
||||||
local cy0=y0\1+1
|
local cy0=y0\1+1
|
||||||
-- sub-pix shift
|
-- sub-pix shift
|
||||||
x0+=(cy0-y0)*dx
|
x0+=(cy0-y0)*dx
|
||||||
for y=y0\1+1,min(y1\1,127) do
|
for y=y0\1+1,min(y1\1,127) do
|
||||||
-- open span?
|
-- open span?
|
||||||
local span=spans[y]
|
local span=spans[y]
|
||||||
if span then
|
if span then
|
||||||
rectfill(x0,y,span,y)
|
rectfill(x0,y,span,y)
|
||||||
else
|
else
|
||||||
spans[y]=x0
|
spans[y]=x0
|
||||||
end
|
|
||||||
x0+=dx
|
|
||||||
end
|
end
|
||||||
x0,y0=_x1,_y1
|
x0+=dx
|
||||||
end
|
end
|
||||||
|
x0,y0=_x1,_y1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _apply(x,ts,a)
|
function _apply(x,ts,a)
|
||||||
|
Loading…
Reference in New Issue
Block a user