Hashcolor

Generate color from a given string.

Hashcolor generates a color for a given string using full RGB range or using a limited set of colors.

Installation

Add this to your application's shard.yml:

dependencies:
  hashcolor:
    github: hugoabonizio/hashcolor.cr

Usage

require "hashcolor"
puts Hashcolor.generate("Hello world") # => 0179A4

Hashcolor.colors = ["006064", "8BC34A", "FF9800"]
Hashcolor.generate("hugo") # => 8BC34A

# Using explicitly
Hashcolor.generate_random("hugo") # => B2F9FF
Hashcolor.generate_set("hugo") # => 006064

Examples

|String|Generated| |---|---| |Hashcolor.generate("Hello world")|#A6755C| |Hashcolor.generate("Hello world!")|#283603| |Hashcolor.generate("[email protected]")|#B3439C| |Hashcolor.generate("D6772A")|#D6772A|

Contributing

  1. Fork it ( https://github.com/hugoabonizio/hashcolor.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors