Skip to content

Instantly share code, notes, and snippets.

@lewdev
Last active May 15, 2024 19:50
Show Gist options
  • Save lewdev/98d35c907b6eee4e982439ecbf7e41ad to your computer and use it in GitHub Desktop.
Save lewdev/98d35c907b6eee4e982439ecbf7e41ad to your computer and use it in GitHub Desktop.
🌌 Punch it Chewie! #StarWars #MillenniumFalcon

🌌 Punch it Chewie! #StarWars #MillenniumFalcon

To celebrate May 4th, I made the cockpit design of the Millennium Falcon fit within a dweet!

🚒 Cockpit of the Millennium Falcon (161b) d/31702

B=~~(t*99)%136
x.save(A=300)
x.translate(960,1080)
x.rotate(B*.035)
for(i=5;i--;)x.fillRect(-70,A+A*i,43,B%25+i%2==0||(B+15)%25+(i+1)%2==0?A:30)
x.restore()

✈ Flying in the Millennium Falcon (291b)

I combined my dweet with one by KilledByAPixel: Tiny Starfield 🌠

I couldn't put the two together into a dweet but it made an interesting combination.

c.style.filter="invert(" didn't work with capjs, so I manually colored the canvas. I removed some starfield code to get it working nicely too.

x.fillStyle="#000"
x.fillRect(0,0,2e3,2e3)

//KilledByAPixel's Tiny Starfield (minus some code)
x.fillStyle="#FFF"
for(j=5e3;r=j--/(9-++t%9);)x.fillRect(C(j)*r+960,S(j*j)*r+540,r>>=8,r)

//cockpit code
for(B=136;B--;){x.save(A=300)
x.translate(960,1080)
x.rotate(B*.035)
for(i=5;i--;)x.fillRect(-70,A+A*i,43,B%25+i%2==0||(B+15)%25+(i+1)%2==0?A:30)
x.restore()}

I used CapJS to generate a webm video file and converted that to mp4.

Hyperspace Jump

c.style.filter="invert("
for(j=5e3;r=j--/(9-++t%9);)x.fillRect(C(j)*r+1e3,S(j*j)*r+540,r>>=8,r)
for(B=136;B--;){x.save(A=300)
x.translate(960,1e3)
x.rotate(B*.035)
for(i=5;i--;)x.clearRect(-70,A+A*i,43,B%25+i%2==0||(B+15)%25+(i+1)%2==0?A:30)
x.restore()}

🌌 Punch it Chewie! #StarWars #MillenniumFalcon #MayTheFourth

To celebrate May 4th, I made the cockpit design of the Millennium Falcon fit within a dweet (https://dwitter.net/d/31702)!

B=~~(t*99)%136
x.save(A=300)
x.translate(960,1080)
x.rotate(B*.035)
for(i=5;i--;)x.fillRect(-70,A+A*i,43,B%25+i%2==0||(B+15)%25+(i+1)%2==0?A:30)
x.restore()

Then I combined my dweet with one by @KilledByAPixel called Tiny Starfield 🌠 (https://www.dwitter.net/d/28307) and captured the video of it using CapJS (https://capjs.3d2k.com/).

Here's more source code: https://gist.github.com/lewdev/98d35c907b6eee4e982439ecbf7e41ad

#MayTheFourth #dwitter #capjs #codegolf #tinycode

<style>html,body{background:#222;display:flex;justify-content:center;align-items:center;height:100%;margin:0}#c{background:white;max-height:100%;max-width:100%}</style><canvas id=c width=1920 height=1080></canvas><script>x=c.getContext`2d`,lfr=1,S=Math.sin,C=Math.cos,T=Math.tan,R=(r,g,b,a=1)=>`rgba(${r|0},${g|0},${b|0},${a})`,t=f=nfm=0;z=t=>{
/* 161b solution */
B=~~(t*99)%136
x.save(A=300)
x.translate(960,1080)
x.rotate(B*.035)
for(i=5;i--;)x.fillRect(-70,A+A*i,43,B%25+i%2==0||(B+15)%25+(i+1)%2==0?A:30)
x.restore()
/* 171b 1-pass solution
for(c.width|=j=136;j--;){x.save(A=300)
x.translate(960,1080)
x.rotate(j*.035)
for(i=5;i--;)x.fillRect(-70,A+A*i,50,j%25+i%2==0||(j+15)%25+(i+1)%2==0?A:30)
x.restore()}
*/
};loop=fTime=>{requestAnimationFrame(loop);if(lfr&&fTime<nfm-2)return;nfm=Math.max(nfm+1e3/60,fTime);t=f/60;if(t*60|0!=f++)t+=1e-6;z(t)};loop()</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment