Skip to content

Instantly share code, notes, and snippets.

@padde
Last active January 29, 2016 20:03
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 padde/d8ccf923fe6ab8c84546 to your computer and use it in GitHub Desktop.
Save padde/d8ccf923fe6ab8c84546 to your computer and use it in GitHub Desktop.
Colored stars (dabbling with ANSI escape codes)
lines = `tput lines`.to_i
cols = `tput cols`.to_i
# hide cursor
print "\e[?25l"
# clear screen
print "\e[2J"
at_exit do
# show cursor
puts "\e[?25h"
# clear screen
print "\e[2J"
# reset color
print "\e[0m"
end
50000.times do |i|
line = rand 1..lines
col = rand 1..cols
r = rand 0..255
g = rand 0..255
b = rand 0..255
# print "\e[48;2;%d;%d;%dm" % [r,g,b]
print "\e[38;2;%d;%d;%dm" % [255-r,255-g,255-b]
print "\e[#{line};#{col}f*"
sleep 0.001
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment