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 =
(Array(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.inject([]) do |slice, colour| bend = (Array(colour) * BEND_LENGTH) BAND_HEIGHT.times do slice << bend.join end slice end
Class Method Summary collapse
Class Method Details
.frame(is_peak = true) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nyan/sprites/rainbow.rb', line 24 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
43 44 45 |
# File 'lib/nyan/sprites/rainbow.rb', line 43 def self.to_frames @frames ||= [frame(true), frame(false)] end |