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 — unless drill color random is set (see
Lexdrill::Color), in which case a vivid random color is used every time
instead.
Constant Summary collapse
- YELLOW =
33- 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_by_count(text, count) ⇒ Object
28 29 30 31 |
# File 'lib/lexdrill/colorizer.rb', line 28 def self.paint_by_count(text, count) code = Lexdrill::Color.random? ? random_code : gradient_code(count) wrap(text, code) end |
.paint_yellow(text) ⇒ Object
24 25 26 |
# File 'lib/lexdrill/colorizer.rb', line 24 def self.paint_yellow(text) wrap(text, YELLOW) end |