phlak/colorizer

Generate persistantly unique colors from a string.

1.4.1 2016-09-24 22:12 UTC

README

Latest Stable Version Total Downloads Author License Build Status

Generate persistently unique colors from a string.

Like this project? Keep me caffeinated by making a donation.

Install with Composer

composer require phlak/colorizer

Usage

// 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)'

Normalizing Colors

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:

$colorize->normalize(64, 224);

Troubleshooting

Please report bugs to the GitHub Issue Tracker.

Copyright

This project is liscensed under the MIT License.