Module: Nyan::Rainbow
- Defined in:
- lib/nyan/sprites/rainbow.rb
Constant Summary collapse
- BAND_HEIGHT =
3
- BEND_LENGTH =
18
- SECTIONS =
5
- COLOURS =
%w(1 2 3 4 5)
- BLANK =
([Nyan::SPACE] * BEND_LENGTH).join
- FRAME_HEIGHT =
COLOURS.length * BAND_HEIGHT + 1
- FRAME_WIDTH =
SECTIONS * BEND_LENGTH
- TOTAL_LENGTH =
SECTIONS * BEND_LENGTH
- TOTAL_HEIGHT =
BAND_HEIGHT * COLOURS.length
- SLICE =
COLOURS.each_with_object([]) do |colour, slice| BAND_HEIGHT.times do slice << "#{colour}" * BEND_LENGTH end end
Class Method Summary collapse
Class Method Details
.frame(is_peak = true) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/nyan/sprites/rainbow.rb', line 22 def self.frame(is_peak = true) frame_rows = Array.new(FRAME_HEIGHT + 1) { String.new } SECTIONS.times do this_slice = SLICE.dup FRAME_HEIGHT.times do |i| this_row = if (is_peak && i == FRAME_HEIGHT - 1) or (!is_peak && i == 0) BLANK else this_slice.shift end frame_rows[i] << this_row end is_peak = !is_peak end frame_rows.join(NEWLINE) end |
.to_frames ⇒ Object
41 42 43 |
# File 'lib/nyan/sprites/rainbow.rb', line 41 def self.to_frames @frames ||= [frame(true), frame(false)] end |