{"name":"Genuary 2023 Day 9 - Plants","description":"-- genuary #9 2023\n-- plants\n-- by carson kompon\n\n-- credits: https://www.lexaloffle.com/bbs/?pid=80095\nfunction linefill(ax,ay,bx,by,r,c)\n\tif(c) color(c)\n\tlocal dx,dy=bx-ax,by-ay\n\t-- avoid overflow\n\t-- credits: https://www.lexaloffle.com/bbs/?tid=28999\n\tlocal d=max(abs(dx),abs(dy))\n\tlocal n=min(abs(dx),abs(dy))/d\n\td*=sqrt(n*n+1)\n\tif(d<0.001) return\n\tlocal ca,sa=dx/d,-dy/d\n\t-- polygon points\n\tlocal s={\n\t\t{0,-r},{d,-r},{d,r},{0,r}\n\t}\n\tlocal u,v,spans=s[4][1],s[4][2],{}\n\tlocal x0,y0=ax+u*ca+v*sa,ay-u*sa+v*ca\n\tfor i=1,4 do\n\t\tlocal u,v=s[i][1],s[i][2]\n\t\tlocal x1,y1=ax+u*ca+v*sa,ay-u*sa+v*ca\n\t\tlocal _x1,_y1=x1,y1\n\t\tif(y0>y1) x0,y0,x1,y1=x1,y1,x0,y0\n\t\tlocal dx=(x1-x0)/(y1-y0)\n\t\tif(y0<0) x0-=y0*dx y0=-1\n\t\tlocal cy0=y0\\1+1\n\t\t-- sub-pix shift\n\t\tx0+=(cy0-y0)*dx\n\t\tfor y=y0\\1+1,min(y1\\1,127) do\n\t\t\t-- open span?\n\t\t\tlocal span=spans[y]\n\t\t\tif span then\n\t\t\t\trectfill(x0,y,span,y)\n\t\t\telse\n\t\t\t\tspans[y]=x0\n\t\t\tend\n\t\t\tx0+=dx\n\t\tend\n\t\tx0,y0=_x1,_y1\n\tend\nend\n\nfunction plot_stem(x,y)\n\tadd(stem,{\n\t\tx=x,y=y\n\t})\nend\n\nfunction get_bloom_pos()\n\ti=#stem\n\tbx=stem[i].x+sin(t()/4+i/8)*2\n\tby=stem[i].y+cos(t()/3+i/8)*2\n\treturn bx,by\nend\n\ncls()\n\nseed={x=63,y=0,c=2,spd=0,growing=false}\nstem={}\npedals={}\nblooming=false\nbloom=0\ngrowthy=120\n\npal({[0]=0,3,4,8,129,1,140,12,7},1)\n\ncls(5)\n::_::\n\t\n\tfor i=1,999 do\n\t\txx=rnd(128)\n\t\tyy=rnd(128)\n\t\tc=7.5-yy/32\n\t\tcircfill(xx,yy,1,c)\n\tend\n\tcircfill(63,999,900,1)\n\t\n\tif not seed.growing then\n\t\tseed.spd+=0.1\n\t\tseed.y+=seed.spd\n\t\tcircfill(seed.x,seed.y,1,seed.c)\n\t\tif seed.y >= 100 then\n\t\t\tseed.growing=true\n\t\t\tgrowthy=seed.y\n\t\tend\n\telse\n\t\tif not blooming then\n\t\t\tgrowthy-=1\n\t\t\tif flr(growthy)%4==0 then\n\t\t\t\tplot_stem(seed.x+sin(t()/2)*4,growthy)\n\t\t\tend\n\t\t\tif(growthy<=40) blooming=true\n\t\telse\n\t\t\t\n\t\tend\n\tend\n\t\n\tfor i=1,#stem do\n\t\tx1=stem[i].x\n\t\ty1=stem[i].y\n\t\tx2=x1\n\t\ty2=y1\n\t\tif i<#stem then\n\t\t\tx2=stem[i+1].x\n\t\t\ty2=stem[i+1].y\n\t\telseif not blooming then\n\t\t\tx2=seed.x+sin(t()/2)*4\n\t\t\ty2=growthy\n\t\tend\n\t\tx1+=sin(t()/4+i/8)*2\n\t\ty1+=cos(t()/3+i/8)*2\n\t\tx2+=sin(t()/4+(i+1)/8)*2\n\t\ty2+=cos(t()/3+(i+1)/8)*2\n\t\tlinefill(x1,y1,x2,y2,1,1)\n\tend\n\t\n\tif blooming then\n\t\tif bloom < 5 then\n\t\t\tbloom+=.2\n\t\t\tif bloom >= 5 then\n\t\t\t\tfor i=1,8 do\n\t\t\t\t\tbx,by=get_bloom_pos()\n\t\t\t\t\tadd(pedals,{\n\t\t\t\t\t\tx=0,y=0,\n\t\t\t\t\t\tdir=i/8,\n\t\t\t\t\t\tdots={},\n\t\t\t\t\t\tl=0,\n\t\t\t\t\t\tupdate=function(self)\n\t\t\t\t\t\t\tif(#self.dots<16 and self.l%6==0)self:plot()\n\t\t\t\t\t\t\tself.l+=1\n\t\t\t\t\t\t\tself.x+=cos(self.dir)*.5\n\t\t\t\t\t\t\tself.y+=sin(self.dir)*.5\n\t\t\t\t\t\t\tself.dir+=.008\n\t\t\t\t\t\t\tbx,by=get_bloom_pos()\n\t\t\t\t\t\t\tfor i=1,#self.dots do\n\t\t\t\t\t\t\t\tx1=bx+self.dots[i].x\n\t\t\t\t\t\t\t\ty1=by+self.dots[i].y\n\t\t\t\t\t\t\t\tx2=x1\n\t\t\t\t\t\t\t\ty2=y1\n\t\t\t\t\t\t\t\tif i<#self.dots then\n\t\t\t\t\t\t\t\t\tx2=bx+self.dots[i+1].x\n\t\t\t\t\t\t\t\t\ty2=by+self.dots[i+1].y\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tx1+=sin(t()/4+i/8)\n\t\t\t\t\t\t\t\ty1+=cos(t()/3+i/8)\n\t\t\t\t\t\t\t\tx2+=sin(t()/4+(i+1)/8)\n\t\t\t\t\t\t\t\ty2+=cos(t()/3+(i+1)/8)\n\t\t\t\t\t\t\t\tlinefill(x1,y1,x2,y2,1,14)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend,\n\t\t\t\t\t\tplot=function(self)\n\t\t\t\t\t\t\tadd(self.dots,{\n\t\t\t\t\t\t\t\tx=self.x,\n\t\t\t\t\t\t\t\ty=self.y\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\tend\n\t\t\t\t\t})\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tfor p in all(pedals) do\n\t\t\t\tp:update()\n\t\t\tend\n\t\tend\n\t\tbx,by=get_bloom_pos()\n\t\tcircfill(bx,by,bloom,2)\n\tend\n\t\n\tflip()\ngoto _","tags":["generative","pixelart","animated","opensource","pico8","pico-8","genuary","genuary9"],"symbol":"OBJKT","artifactUri":"ipfs://bafybeicaeezvrvvmqt5a4mbbac3v2ddsp7qupxge3eiyufwppcphrzdhbi","displayUri":"ipfs://QmdZzkhhorfC4k1JMdwsFcaBnS2GJzKFd2fGMDE5gQoSrw","thumbnailUri":"ipfs://QmdZzkhhorfC4k1JMdwsFcaBnS2GJzKFd2fGMDE5gQoSrw","creators":["tz1XqJ9e6NdouxdGvm2V3aknwFnGL6Kinu6A"],"formats":[{"fileSize":1000672,"fileName":"genuary_2023_9.zip","mimeType":"application/x-directory","uri":"ipfs://bafybeicaeezvrvvmqt5a4mbbac3v2ddsp7qupxge3eiyufwppcphrzdhbi"},{"mimeType":"image/gif","fileSize":846101,"fileName":"cover_genuary_2023_9.gif","dimensions":{"value":"512x512","unit":"px"},"uri":"ipfs://QmdZzkhhorfC4k1JMdwsFcaBnS2GJzKFd2fGMDE5gQoSrw"},{"mimeType":"image/gif","fileSize":846101,"fileName":"thumbnail_genuary_2023_9.gif","dimensions":{"value":"512x512","unit":"px"},"uri":"ipfs://QmdZzkhhorfC4k1JMdwsFcaBnS2GJzKFd2fGMDE5gQoSrw"}],"decimals":0,"isBooleanAmount":false,"shouldPreferSymbol":false,"rights":"none","date":"2023-01-09T18:29:54.403Z","mintingTool":"https://teia.art/mint"}