Save a handful of tokens and fix indentation. (#2)

Reviewed-on: pyrex/chameleonic#2
Co-authored-by: Kistaro Windrider <kistaro@gmail.com>
Co-committed-by: Kistaro Windrider <kistaro@gmail.com>
This commit is contained in:
Kistaro Windrider 2022-12-17 23:51:50 +00:00 committed by Pyrex
parent 0ff3065585
commit d0eba82c7b

View File

@ -22,7 +22,6 @@ function names(root)
end
function _doall(x)
for n in names(x) do
for mod in all(modules) do
local f=mod[n]
@ -32,13 +31,12 @@ function _doall(x)
end
-- 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}
function shellsort(a)
for gap in all(gaps) do
for i=gap+1,#a do
local x=a[i]
local j=i-gap
local x,j=a[i],i-gap
while j>=1 and a[j].key>x.key do
a[j+gap]=a[j]
j-=gap
@ -57,36 +55,36 @@ function linefill(ax,ay,bx,by,r,c)
local n=min(abs(dx),abs(dy))/d
d*=sqrt(n*n+1)
if(d<0.001) return
local ca,sa=dx/d,-dy/d
local ca,sa=dx/d,-dy/d
-- polygon points
local s={
{0,-r},{d,-r},{d,r},{0,r}
}
local u,v,spans=s[4][1],s[4][2],{}
local x0,y0=ax+u*ca+v*sa,ay-u*sa+v*ca
for i=1,4 do
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=x1,y1
if(y0>y1) x0,y0,x1,y1=x1,y1,x0,y0
local dx=(x1-x0)/(y1-y0)
if(y0<0) x0-=y0*dx y0=-1
local cy0=y0\1+1
-- sub-pix shift
x0+=(cy0-y0)*dx
for y=y0\1+1,min(y1\1,127) do
-- open span?
local span=spans[y]
if span then
rectfill(x0,y,span,y)
else
spans[y]=x0
end
x0+=dx
-- polygon points
local s={
{0,-r},{d,-r},{d,r},{0,r}
}
local u,v,spans=s[4][1],s[4][2],{}
local x0,y0=ax+u*ca+v*sa,ay-u*sa+v*ca
for i=1,4 do
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=x1,y1
if(y0>y1) x0,y0,x1,y1=x1,y1,x0,y0
local dx=(x1-x0)/(y1-y0)
if(y0<0) x0-=y0*dx y0=-1
local cy0=y0\1+1
-- sub-pix shift
x0+=(cy0-y0)*dx
for y=y0\1+1,min(y1\1,127) do
-- open span?
local span=spans[y]
if span then
rectfill(x0,y,span,y)
else
spans[y]=x0
end
x0,y0=_x1,_y1
x0+=dx
end
x0,y0=_x1,_y1
end
end
function _apply(x,ts,a)