Colored stars (dabbling with ANSI escape codes)
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
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