hashcolor.cr

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("hugo@email.com") #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

Repository

hashcolor.cr

Owner
Statistic
  • 1
  • 0
  • 0
  • 0
  • 0
  • almost 7 years ago
  • May 21, 2017
License

MIT License

Links
Synced at

Fri, 03 May 2024 02:10:47 GMT

Languages