Module: Lexdrill::Colorizer
- Defined in:
- lib/lexdrill/colorizer.rb
Overview
Wraps text in an ANSI color code. paint_by_count maps a word's show
count onto a blue -> red truecolor gradient, one step per
Lexdrill::Stats::BUCKET_SIZE shows, so a word's color reflects how many
times it's been drilled — except on an even count, where a random vivid
color is used instead, for a bit of visual variety.
Constant Summary collapse
- BLUE =
34- GRADIENT_STEPS =
Lexdrill::Stats::GRADUATION_THRESHOLD / Lexdrill::Stats::BUCKET_SIZE
- HUE_DEGREES =
360- SEXTANT_CHANNELS =
Which of trough, 0 each RGB channel takes in each 60-degree hue sextant, walking red -> yellow -> green -> cyan -> blue -> magenta -> red.
[ %i[peak trough zero], %i[trough peak zero], %i[zero peak trough], %i[zero trough peak], %i[trough zero peak], %i[peak zero trough] ].freeze
Class Method Summary collapse
Class Method Details
.paint_blue(text) ⇒ Object
23 24 25 |
# File 'lib/lexdrill/colorizer.rb', line 23 def self.paint_blue(text) wrap(text, BLUE) end |
.paint_by_count(text, count) ⇒ Object
27 28 29 30 |
# File 'lib/lexdrill/colorizer.rb', line 27 def self.paint_by_count(text, count) code = count.even? ? random_code : gradient_code(count) wrap(text, code) end |