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")
||
|Hashcolor.generate("Hello world!")
||
|Hashcolor.generate("[email protected]")
||
|Hashcolor.generate("D6772A")
||
Contributing
- Fork it ( https://github.com/hugoabonizio/hashcolor.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- hugoabonizio Hugo Abonizio - creator, maintainer