alistairshaw / name-the-color
提供从十六进制值到颜色名称,以及从颜色名称到十六进制值的转换
0.1.1
2016-04-23 00:04 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: ~5
This package is not auto-updated.
Last update: 2024-09-26 01:10:13 UTC
README
通过 Composer
$ composer require alistairshaw/name-the-color:0.1.*
使用方法
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() . ')';
贡献
非常欢迎贡献,并将得到充分认可,只需请确保添加测试。
鸣谢
对 Chirag Mehta 的许多感谢,他在 2007 年用 JavaScript 实现了这个功能。(http://chir.ag/projects/ntc/)。颜色列表来自他的网站,以及转换十六进制代码的方法。
许可证
MIT 许可证 (MIT)。