forked from dphase/cube
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcube.rb
More file actions
executable file
·45 lines (34 loc) · 936 Bytes
/
cube.rb
File metadata and controls
executable file
·45 lines (34 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env ruby
require "colorize" # gem install colorize
require "terminfo" # gem install ruby-terminfo
cube = %Q{
MERRY CHRISTMAS
__________
/| /|
/ | / |
/__|______/ |
| |______|__|
| / | /
| / | /
|/________|/
#iMPULSE
}.split("\n")
def enjoy(cube)
offset, mode = 0, 1
loop do
# clear screen
puts "\e[2J\e[f"
# alter left/right modes -- allow for dynamic window width
mode = 0 if offset == (TermInfo.screen_size[1] - cube.collect{|c| c.length }.max)
mode = 1 if offset == 0
# modify the offset
offset = mode == 1 ? offset + 1 : offset - 1
# only do the multiplication once.
spacing = ' ' * offset
# puts the cube w/ color!
puts cube.collect{ |c| spacing + c }.join("\n").colorize(String.colors[offset % String.colors.length])
# enjoy christmas cheer and sleep for a bit.
sleep 0.0275
end
end
enjoy(cube)