This library will allow you to alter colors, check readability, and generate different palettes based on a base color.
Via Composer
$ composer require mikealmond/color
$color = Color::fromHex('FFFFFF');
echo $color->getRgb()['b']; // 255
/** @var Color $darkerColor */
$darkerColor = $color->darken(50); // 50% darker
echo $darkerColor; // implements `__toString()`
if ($darkerColor->isDark()) {
// do something with a dark color
}
// Create a color palette based on #663399
$color = Color::fromCssColor('RebeccaPurple');
$generator = new PaletteGenerator($color);
$palette = $generator->triad(40);
foreach ($palette as $color) {
printf(
'<div style="background-color:%s;color:%s;text-align:center;">%s</div>',
CssGenerator::hex($color),
CssGenerator::hex($color->getMatchingTextColor()),
CssGenerator::rgb($color)
);
}
Please see CHANGELOG for more information what has changed recently.
$ composer test
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.