Read more

Hash any Ruby object into an RGB color

Dominik Schöler
April 29, 2014Software engineer at makandra GmbH

If you want to label things with a color but don't actually care which cholor, you can use the attached Colorizer class.

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

To get a completely random color (some of which will clash with your design):

Colorizer.colorize(some_object) # => "#bb4faa"

To get similiar colors (e. g. bright, pale colors of different hues):

 # random hue, saturation of 0.5, lightness of 0.6
Colorizer.colorize_similarly(some_object, 0.5, 0.6) # => "#bbaaaa"

Also see the color gem Show archive.org snapshot .

Posted by Dominik Schöler to makandra dev (2014-04-29 15:48)