Skip to content

Instantly share code, notes, and snippets.

@JoshCheek
Created May 22, 2017 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshCheek/2438c500e5d937e134e9eb6c19cf6617 to your computer and use it in GitHub Desktop.
Save JoshCheek/2438c500e5d937e134e9eb6c19cf6617 to your computer and use it in GitHub Desktop.
Spin round
require'io/console'
include Math
p,t=PI,"You spin me right round baby, right round round round."
.split(/\b/).flat_map.with_index{|w,i|w.chars.map{|c|"\e[9#{i%7+1}m#{c}"}}+
(" "*10).chars
r,ø=t.size/2/p,2*p/t.size
$><<"\e[H\e[2J\e[?25l"
at_exit{$><<"\e[?25h"}
loop.with_index{|*,c|t.each.with_index(-c){|c,i|print"\e[#{
(sin(ø*i)*r+r+1).to_i};#{(cos(ø*i)*r*2+r*2+1).to_i}H#{c}"}
sleep 0.1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment