-- genuary #11 2023
-- suprematism
-- by carson kompon
-- credit: https://www.lexaloffle.com/bbs/?tid=34282
function draw_polygon(points)
local xl,xr,ymin,ymax={},{},129,0xffff
for k,v in pairs(points) do
local p2=points[k%#points+1]
local x1,y1,x2,y2=v[1],flr(v[2]),p2[1],flr(p2[2])
if y1>y2 then
y1,y2,x1,x2=y2,y1,x2,x1
end
local d=y2-y1
for y=y1,y2 do
local xval=flr(x1+(x2-x1)*(d==0 and 1 or (y-y1)/d))
xl[y],xr[y]=min(xl[y] or 32767,xval),max(xr[y] or 0x8001,xval)
end
ymin,ymax=min(y1,ymin),max(y2,ymax)
end
for y=ymin,ymax do
rectfill(xl[y],y,xr[y],y)
end
end
-- this function took me too long to write bc it's nearly 9pm
function rectfillrot(x,y,w,h,r)
w/=2
h/=2
points={}
add(points,{
x-cos(r)*w-cos(r+.25)*h,
y-sin(r)*w-sin(r+.25)*h
})
add(points,{
x+cos(r)*w-cos(r+.25)*h,
y+sin(r)*w-sin(r+.25)*h
})
add(points,{
x+cos(r)*w+cos(r+.25)*h,
y+sin(r)*w+sin(r+.25)*h
})
add(points,{
x-cos(r)*w+cos(r+.25)*h,
y-sin(r)*w+sin(r+.25)*h
})
draw_polygon(points)
end
tears={}
counter=0
::_::
cls(0)
color(1)
if counter%12==0 then
add(tears,{
x=24+((rnd(2)\1)*80),
y=24,spd=0,r=3+rnd(2)-1
})
end
for tear in all(tears) do
tear.spd+=0.1
tear.y+=tear.spd
circfill(tear.x,tear.y,tear.r)
if(tear.y>=132)del(tears,tear)
end
color(8)
rectfillrot(24,24,32,8,t()/4)
rectfillrot(24,24,32,8,-t()/4)
rectfillrot(104,24,32,8,t()/4)
rectfillrot(104,24,32,8,-t()/4)
color(9)
rectfillrot(64,54,28,10,-.125)
rectfill(49,60,77,68)
rectfill(63-12,80,63+12,82)
rectfill(63-18,86,63+18,90)
color(10)
rectfillrot(42,100,82,6,-.0625)
rectfillrot(128-42,100,82,6,.0625)
color(4)
rectfill(63-42,100,63+42,108)
counter+=1
flip()
goto _