Generate persistantly unique colors from a string.
Generate persistently unique colors from a string.
Like this project? Keep me caffeinated by making a donation.
- PHP >= 5.4
composer require phlak/colorizer
// Import Colorizer use Colorizer; // Initialize Colorizer $colorize = new Colorizer\Colorize(); // Generate a hex color code from 'foo' $hexColor = $colorize->toHex('foo'); // Returns '#a5c4e0' // Generate a RGB color code from 'bar' $rgbColor = $colorize->toRGB('bar'); // Returns 'rgb(238, 215, 222)'
You can enforce RGB values to fall within a certain range to prevent colors from being too bright or dark. This is possible by passing minimum and maximum normalization values (0-255) to the Colorize class on initialization:
$colorize = new Colorizer\Colorize(64, 224);
or on an already existing object:
Please report bugs to the GitHub Issue Tracker.
This project is liscensed under the MIT License.