alistairshaw / name-the-color
Provide color names from hex values and hex values for color names
Installs: 1 670
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 2
Open Issues: 1
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: ~5
This package is not auto-updated.
Last update: 2024-11-21 02:02:17 UTC
README
Via Composer
$ composer require alistairshaw/name-the-color:0.1.*
Usage
require 'vendor/autoload.php'; use AlistairShaw\NameTheColor\ColorMaker; // You can get a Color object from a hex code. It will find the closest named color to your hex. $color = ColorMaker::fromHex('#FF0000'); // or from the name of the color $color = ColorMaker::fromString('Red'); // once you have the color object you can get the resulting color like so: echo $color->getName() . ' - ' . $color->getHex() . ' (' . $color->getOriginalHex() . ')';
Contributing
Contributions are very welcome and will be fully credited, just please make sure to add tests.
Credits
Lots of credit to Chirag Mehta who came up with this in Javascript back in 2007. (http://chir.ag/projects/ntc/). The list of colors comes from his website as well as the method for converting hex codes.
License
The MIT License (MIT).