Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'io/console'
- console_xy = IO.console.winsize
- SIZEY = console_xy[0]
- COLWIDTH = 3#self explanatory, each bar will have this width in chars
- SEPARATOR = 1#number of cols separating two bars
- SIZEX =console_xy[1]/(COLWIDTH+SEPARATOR)
- count = []
- SIZEX.times do
- o = rand(SIZEY)
- count << o
- end
- loop do
- a = []
- SIZEX.times do |i|
- o2 = count[i] + rand(-1..1)
- count[i] = o2 > SIZEY ? SIZEY : (o2 < 0 ? 0 : o2)
- COLWIDTH.times do
- a << ([" "]*count[i] + ["♪"]*(SIZEY-count[i]))
- end
- SEPARATOR.times{ a << [" "]*SIZEY}
- end
- sleep 0.1
- system('clear') || system('cls')
- puts a.transpose.map(&:join).join("\n")
- end
Add Comment
Please, Sign In to add comment