From ed62ae1b7798a8101aa597f954a25c8644ed137a Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sat, 17 Dec 2022 15:49:13 -0800 Subject: [PATCH] Save a handful of tokens and fix indentation. --- chameleonic.p8 | 60 ++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/chameleonic.p8 b/chameleonic.p8 index be47bae..6037265 100644 --- a/chameleonic.p8 +++ b/chameleonic.p8 @@ -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)