-- genuary #11 2024
-- in the style of anni albers (1899-1994)
-- by carson kompon
-- left click to generate a new painting
-- right click to save a seamless gif
poke(0x5f2d,1)
lastclick=0
function _init()
?rnd({"\^!5f10?●74웃ˇ█","\^!5f10?567=♪🐱","\^!5f10?ˇ█●◆🅾️🐱","\^!5f106█⬇️▒1=ˇ"})
cls()
gw=8+rnd(8)
gh=6+rnd(20)
w=flr(92/gw)
h=flr(120/gh)
www=w*gw
hhh=h*gh
o={}
local i=0
local xx=0
local yy=0
local ww=1
local hh=1
while i<(w*h)do
ww=1
hh=1
if(rnd()<.1)ww=flr(rnd(3))+1
if(rnd()<.1)hh=flr(rnd(3))+1
ww=min(ww,w-xx)
hh=min(hh,h-yy)
local z=flr(rnd(2))
for j=0,z do
local f=rnd({spawn_rect,spawn_hlines,spawn_vlines})
f(xx*gw,yy*gh,ww,hh)
end
i+=ww
xx+=ww
if(xx>=w)then
xx-=w
yy+=1
end
end
camera(-(128-(gw*w))/2,-(128-(gh*h))/2)
end
function _update60()
cls()
for s in all(o)do
s:update()
end
local click=stat(34)
if(click==1and lastclick==0)_init()
if(click==2and lastclick==0)extcmd("video")
lastclick=click
end
function spawn_rect(xx,yy,ww,hh)
local s={
x=xx,
y=yy,
w=gw*ww,
h=gh*hh,
c=rnd(6)+1,
d=0,
s=rnd({2,4,8,16}),
update=function(s)
if(s.d==0)rectfill(s.x,s.y,s.x+s.w,s.y+s.h,s.c)
if(s.d==1)rectfill(s.x,s.y,s.x+s.w*(sin(t()/s.s)/2+.5),s.y+s.h,s.c)
if(s.d==2)rectfill(s.x+s.w*(sin(t()/s.s)/2+.5),s.y,s.x+s.w,s.y+s.h,s.c)
if(s.d==3)rectfill(s.x,s.y,s.x+s.w,s.y+s.h*(sin(t()/s.s)/2+.5),s.c)
if(s.d==4)rectfill(s.x,s.y+s.h*(sin(t()/s.s)/2+.5),s.x+s.w,s.y+s.h,s.c)
end
}
if(rnd()<.1)s.d=flr(1+rnd(4))
add(o,s)
end
function spawn_hlines(xx,yy,ww,hh)
local s={
x=xx,
y=yy,
w=gw*ww,
h=gh*hh,
c=rnd(6)+1,
d=flr(rnd(2)),
s=0.2+rnd(10),
z=rnd({2,4,8,16}),
update=function(s)
if s.d==0 then
for i=2,s.w-4,4do
if(s.y+i<hhh-2)rectfill(s.x,s.y+i,s.x+s.w*(sin(t()/4+i/64*s.z)/2+.5),s.y+i+2,s.c)
end
else
for i=2,s.w-4,4do
if(s.y+i<hhh-2)rectfill(s.x+s.w*(sin(t()/4+i/64*s.z)/2+.5),s.y+i,s.x+s.w,s.y+i+2,s.c)
end
end
end
}
add(o,s)
end
function spawn_vlines(xx,yy,ww,hh)
local s={
x=xx,
y=yy,
w=gw*ww,
h=gh*hh,
c=rnd(6)+1,
d=flr(rnd(2)),
s=0.2+rnd(10),
z=rnd({2,4,8,16}),
update=function(s)
if s.d==0 then
for i=2,s.h-4,4do
if(s.x+i<www-2)rectfill(s.x+i,s.y,s.x+i+2,s.y+s.h*(sin(t()/4+i/64*s.z)/2+.5),s.c)
end
else
for i=2,s.h-4,4do
if(s.x+i<www-2)rectfill(s.x+i,s.y+s.h*(sin(t()/4+i/64*s.z)/2+.5),s.x+i+2,s.y+s.h,s.c)
end
end
end
}
add(o,s)
end
function lerp(x,y,t)
return x+(y-x)*t
end