Created
December 19, 2014 19:52
-
-
Save anshdivu/a2349630ed63834b1c31 to your computer and use it in GitHub Desktop.
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
screen_width = `stty size`.scan(/\d+/)[1].to_i; | |
snow_char = ["2743".to_i(16)].pack("U*"); | |
# clear screen | |
puts "\033[2J"; | |
screen = {}; # screen as a 2D array | |
loop { | |
# select random column in first row of screen | |
screen[rand(screen_width)] = 0; | |
# run snowflakes down the screen | |
screen.each { |row, col| | |
screen[row] += 1; | |
# print snowflake on screen | |
print "\033[#{col};#{row}H \033[#{screen[row]};#{row}H#{snow_char} \033[0;0H" | |
}; | |
$stdout.flush; | |
sleep 0.1 | |
} | |
Author
anshdivu
commented
Dec 19, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment