Sha256: 9cd534487b6f7ce22230ff67441e400757f8211a90ba7f7c0ff9e36153a8a84c

Contents?: true

Size: 886 Bytes

Versions: 22

Compression:

Stored size: 886 Bytes

Contents

module Coltrane
  module Renderers
    module TextRenderer
      class TheoryScaleSetDrawer < BaseDrawer
        alias scale_set model

        def render
          output = []
          scale_width = scale_set.results.keys.map(&:size).max
          scale_set.results.each do |name, scales_by_tone|
            output << name.ljust(scale_width + 1, ' ')
            scales_by_tone.each do |tone_number, notes|
              p     = (notes.size.to_f / scale_set.searched_notes.size) * 100
              l     = p == 100 ? p : (p + 20) * 0.4
              und   = p == 100 ? :underline : nil
              color = Color::HSL.new(30, p, l / 2).html
              output << Paint["#{Theory::Note[tone_number].name}(#{notes.size})", color, und]
              output << ' '
            end
            output << "\n"
          end
          output.join
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
coltrane-4.1.2 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-4.1.1 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-4.1.0 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-4.0.6 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-4.0.5 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-4.0.4 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-4.0.3 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-3.4.2 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-3.4.1 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-3.4.0 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-3.3.3 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-3.3.2 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-3.3.1 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-3.3.0 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-3.2.0 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-3.1.3 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-3.1.2 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-3.1.1 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-3.1.0 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb
coltrane-3.0.0 lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb