Top Level Namespace
Defined Under Namespace
Modules: Textkolor
Instance Method Summary collapse
Instance Method Details
#textkolor(str) ⇒ Object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/textkolor.rb', line 1 def textkolor(str) hash = 11 for i in 0..str.length-1 hash = str[i].ord + ((hash << 5) - hash) end colour = "#" for j in (0).upto(5) value = (hash >> (j * 8) & 0xFF) colour += "00#{value.to_s(16)}"[-2] end colour end |