Method: Inker::Color::Tools#from_custom_string
- Defined in:
- lib/inker/color/tools.rb
#from_custom_string(custom_string, positions: [0, 29, 14, 30, 28, 31]) ⇒ Inker::Color
Use MD5 digest of the string to get hex values from specified positions (by default [0, 29, 14, 30, 28, 31])
in order to obtain a color in HEX format which represents the specified string.
244 245 246 247 |
# File 'lib/inker/color/tools.rb', line 244 def from_custom_string(custom_string, positions: [0, 29, 14, 30, 28, 31]) digest = Digest::MD5.hexdigest(custom_string.to_s) Inker.color("##{positions.map { |p| digest[p] }.join}") end |