Last active
June 8, 2019 18:19
-
-
Save JoshCheek/648f93f1676d395016fd97744f718090 to your computer and use it in GitHub Desktop.
You spin me right round (iterations)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tweet: https://twitter.com/josh_cheek/status/1137422115181871104 | |
# Video: https://vimeo.com/341108197 | |
# 1 | |
node -e h=$LINES,w=$COLUMNS,p=process,t=0,T=6.28,s='"" | |
p.stdin.setRawMode(1).on("data",k=>k[0]-3?s+=k:p.exit()) | |
setInterval(()=>{++t;p.stdout.write(`\x1b[2J`) | |
l=s.length+5 | |
r=l/T | |
x=i=>Math.round(Math.cos(T*(i-t)/l)*r*2+r*2)+1 | |
y=i=>Math.round(Math.sin(T*(i-t)/l)*r+r)+1 | |
p.stdout.write(s.split(/\b/).map( | |
(w,i)=>w.split("").map(c=>`\x1b[9${i%7+1}m`+c) | |
).flat().map((c,i)=>`\x1b[${y(i)};${x(i)}H`+c).join("")) | |
},100)' | |
# 2 | |
node -e p=process,t=0,T=6.28,M=Math,R=M.round,s='"" | |
W=s=>p.stdout.write(s) | |
p.stdin.setRawMode(1).on("data",k=>k[0]-3?s+=k:p.exit()) | |
setInterval(()=>{++t | |
W(`\x1b[2J`) | |
l=s.length+5 | |
r=l/T | |
x=i=>R(M.cos((i-t)/r)*r+r)*2+1 | |
y=i=>R(M.sin((i-t)/r)*r+r)+1 | |
W(s.split(/\b/).map((w,i)=>w.split("").map(c=>`\x1b[9${i%7+1}m`+c)).flat().map((c,i)=>`\x1b[${y(i)};${x(i)}H`+c).join("")) | |
},99)' | |
# 3, 58 away | |
node -e p=process,t=0,M=Math,s='"" | |
p.stdin.setRawMode(1).on("data",k=>k[0]-3?s+=k:p.exit()) | |
setInterval(()=>{++t | |
l=s.length+5 | |
r=l/6.28 | |
q=(f,i,m)=>M.round(f((i-t)/r)*r+r)*m+1 | |
p.stdout.write(`\x1b[2J`+s.split(/\b/).flatMap((w,i)=>w.split("").map(c=>`\x1b[9${i%7+1}m`+c)).map((c,i)=>`\x1b[${q(M.sin,i,1)};${q(M.cos,i,2)}H`+c).join(""))},99)' | |
# 4, 44 away | |
node -e p=process,t=0,M=Math,s='"" | |
p.stdin.setRawMode(1).on("data",k=>k[0]-3?s+=k:p.exit()) | |
setInterval(()=>{++t | |
r=s.length/6.28 | |
q=(f,i)=>M.round(f((i-t)/r)*r+r)+1 | |
p.stdout.write(`\x1b[2J`+s.split(/\b/).flatMap((w,i)=>w.split("").map(c=>`\x1b[9${i%7+1}m`+c)).map((c,i)=>`\x1b[${q(M.sin,i)};${q(M.cos,i)}H`+c).join(""))},99)' | |
# 5, 40 away | |
node -e p=process,t=0,M=Math,s='"" | |
p.stdin.setRawMode(1).on("data",k=>k[0]-3?s+=k:p.exit()) | |
setInterval(()=>{++t | |
r=s.length/6.28 | |
q=(f,i)=>M.round(f((i-t)/r)*r+r)+1 | |
o=0 | |
p.stdout.write(`\x1b[2J`+s.split(/\b/).map((w,wi)=>w.split("").map(c=>`\x1b[9${wi%7+1}m\x1b[${q(M.sin,o)};${q(M.cos,o++)}H`+c).join("")).join(""))},99)' | |
# 6, 29 away | |
node -e p=process,t=0,M=Math,s='"" | |
p.stdin.setRawMode(1).on("data",k=>k[0]-3?s+=k:p.exit()) | |
setInterval(()=>{r=s.length/6.28 | |
q=(f,i)=>M.round(f((i-t)/r)*r+r)+1 | |
o=-++t | |
S="" | |
s.split(/\b/).map((w,i)=>w.split("").map(c=>S+=`\x1b[9${i%7+1}m\x1b[${q(M.sin,o)};${q(M.cos,o++)}H`+c)) | |
p.stdout.write(`\x1b[2J`+S)},99)' | |
# 7, 26 away | |
node -e p=process,t=0,M=Math,s='"" | |
p.stdin.setRawMode(1).on("data",k=>k[0]-3?s+=k:p.exit()) | |
setInterval(()=>{r=s.length/6.28 | |
q=(f,i)=>M.round(f((i+t)/r)*r+r+1) | |
o=--t | |
S="" | |
s.split(/\b/).map((w,i)=>w.split("").map(c=>S+=`\x1b[9${i%7}m\x1b[${q(M.sin,o)};${q(M.cos,o++)}H`+c)) | |
p.stdout.write(`\x1b[2J`+S)},99)' | |
# 8, 34 away >.< regression | |
node -e 'let{exit:e,stdin:I,stdout:O}=process,t=0,M=Math,s="" | |
I.setRawMode(1).on("data",k=>k[0]-3?s+=k:e()) | |
setInterval(()=>{r=s.length/6.3 | |
q=(o,i)=>M.round(M.sin((i+t)/r+o)*r+r+1) | |
j=--t | |
S="" | |
s.split(/\b/).map((w,i)=>w.split("").map(c=>S+=`\x1b[9${i%7}m\x1b[${q(0,j)};${q(1.6,j++)}H`+c)) | |
O.write(`\x1b[2J`+S)},99)' | |
# 9, 22 away | |
node -e p=process,t=0,s='"" | |
p.stdin.setRawMode(1).on("data",k=>k[0]-3?s+=k:p.exit()) | |
setInterval(()=>{r=s.length/6.3 | |
q=(o,i)=>parseInt(Math.sin((i+t)/r+o)*r+r+1) | |
o=--t | |
S="" | |
s.split(/\b/).map((w,i)=>w.split("").map(c=>S+=`\x1b[9${i%7}m\x1b[${q(0,o)};${q(1.6,o++)}H`+c)) | |
p.stdout.write(`\x1b[2J`+S)},99)' | |
# 10, 16 away | |
node -e 'p=process,t=0,s="" | |
p.stdin.setRawMode(1).on("data",k=>k[0]-3?s+=k:p.exit()) | |
setInterval(()=>{r=s.length/6.3 | |
q=(o,i)=>~~(Math.sin((i+t)/r+o)*r+r+1) | |
o=--t | |
S="" | |
s.split(/\b/).map((w,i)=>w.split("").map(c=>S+=`\x1b[9${i%7}m\x1b[${q(0,o)};${q(1.6,o++)}H`+c)) | |
p.stdout.write(`\x1b[2J`+S)},99)' | |
# 11, 13 away | |
node -e 'p=process,t=0,s="" | |
p.stdin.setRawMode(1).on("data",k=>k[0]-3?s+=k:p.exit()) | |
setInterval(()=>{r=s.length/6.3 | |
q=(o,i)=>~~(1+r+r*Math.sin(i/r+t/r+o)) | |
o=--t | |
S="" | |
s.split(/\b/).map((w,i)=>w.split("").map(c=>S+=`\x1b[9${i%7}m\x1b[${q(0,o)};${q(1.6,o++)}H`+c)) | |
console.log(`\x1b[2J`+S)},99)' | |
# 12 | |
node -e 't=0,s="" | |
process.stdin.setRawMode(1).on("data",k=>k[0]-3?s+=k:F) | |
setInterval((j=--t)=>{S="" | |
r=s.length/6.3 | |
q=(o,i)=>~~(1+r+r*Math.sin(i/r+t/r+o)) | |
s.split(/\b/).map((w,i)=>w.split("").map(c=>S+=`\x1b[9${i%7}m\x1b[${q(0,j)};${q(1.6,j++)}H`+c)) | |
console.log(`\x1b[2J`+S)},99)' | |
# 13 | |
node -e 't=0,s="",p=process | |
p.stdin.on("data",d=>s+=d) | |
setInterval((j=--t)=>{S="" | |
r=s.length/6.3 | |
q=(o,i)=>~~(1+r+r*Math.sin(i/r+t/r+o)) | |
s.split(/\b/).map((w,i)=>w.split("").map(c=>S+=`\x1b[9${i%7}m\x1b[${q(0,j)};${q(1.6,j++)}H`+c)) | |
p.stdout.write(`\x1b[2J`+S)},99)' | |
# 14 zero, baby! | |
node -e 't=0,s="",p=process | |
p.stdin.on("data",d=>s=""+d) | |
setInterval((j=--t)=>{S="" | |
r=(s.length+5)/6.3 | |
q=(o,i)=>~~(1+r+r*Math.sin(i/r+t/r/9+o)) | |
s.split(/\n|\b/).map((w,i)=>w.split("").map(c=>S=`\x1b[9${i%7}m\x1b[${q(0,j)};${q(1.6,j++)}H`+c+S)) | |
s&&p.stdout.write(`\x1b[2J`+S)},99)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment