Method: Inker::Color::Tools#random
- Defined in:
- lib/inker/color/tools.rb
#random(with_alpha: false) ⇒ Inker::Color
Generate a random Inker::Color.
182 183 184 185 186 187 188 |
# File 'lib/inker/color/tools.rb', line 182 def random(with_alpha: false) prefix = with_alpha ? 'rgba' : 'rgb' values = (1..3).map{ (rand * 255).round } values << rand.round(2) if with_alpha Inker.color("#{prefix}(#{values.join(',')})") end |