bitandblack / colors
轻松处理颜色及其系统。基于Adobe InDesign的颜色手册。
2.12.0
2023-10-20 12:37 UTC
Requires
- php: >=7.2
- ext-json: *
- bitandblack/sentence-construction: ^1.2 || ^2.0
- myclabs/php-enum: ^1.7
Requires (Dev)
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^9.0
- rector/rector: ^0
- symplify/easy-coding-standard: ^12.0
README
颜色
轻松处理颜色及其系统。基于Adobe InDesign的颜色手册。包含的库有
- HKS E Process
- HKS E
- HKS K Process
- HKS K
- HKS N Process
- HKS N
- HKS Z Process
- HKS Z
- PANTONE+ CMYK Coated
- PANTONE+ CMYK Uncoated
- PANTONE+ Color Bridge Coated
- PANTONE+ Color Bridge Uncoated
- PANTONE+ Metallic Coated
- PANTONE+ Pastels + Neons Coated
- PANTONE+ Pastels + Neons Uncoated
- PANTONE+ Premium Metallics Coated
- PANTONE+ Solid Coated
- PANTONE+ Solid Uncoated
- RAL
注意
此存储库旨在获取PANTONE、HEX或RAL颜色的值。由于从一种系统转换到另一种系统的转换方法不同,因此转换并不完美,请勿过分依赖这些值。
安装
此库是为与Composer一起使用而制作的。通过运行$ composer require bitandblack/colors
将其添加到您的项目中。
使用方法
您可以使用颜色值或颜色系统,具体取决于您的需求。
不同颜色系统中的颜色值
设置颜色如下
<?php
use Color\Value\CMYK;
$red = new CMYK(0, 100, 90, 0);
或者当颜色基于库时
<?php
use Color\Value\PANTONE as PANTONEValue;
use Color\System\PANTONE as PANTONESystem;
use Color\System\Enum\PANTONE as PANTONEEnum;
$pantoneSolidCoated = new PANTONESystem(
PANTONEEnum::PANTONE_PLUS_SOLID_COATED()
);
$red = new PANTONEValue('200', $pantoneSolidCoated);
可用的颜色系统有
CIELab
CMY
CMYK
HEX
HKS
HSL
HSLA
PANTONE
RAL
RGB
RGBA
XYZ
通过调用获取另一个颜色系统的值
<?php
$sameRedDifferentValue = $red->getRGB();
颜色系统和相似值
在PANTONE、HKS和RAL的颜色系统中,您可以通过调用找到基于RGB、HEX或CMYK值的(相似)颜色
<?php
use Color\Value\CMYK as CMYKValue;
use Color\System\PANTONE as PANTONESystem;
use Color\System\Enum\PANTONE as PANTONEEnum;
$pantoneSolidCoated = new PANTONESystem(
PANTONEEnum::PANTONE_PLUS_SOLID_COATED()
);
$red = new CMYKValue(0, 100, 90, 0);
$redsInPantone = $pantoneSolidCoated->findColor($red, 0);
findColor()
中的第二个参数定义了容差百分比。例如,0
返回只有100%匹配的结果,而5
允许返回每个颜色值都相差约5%的颜色。
互补色
您可以通过调用getComplementary()
来获取互补色。这将返回一个HSL
颜色,您可以将它转换为其他系统。
帮助
如果您有任何问题,请随时通过hello@bitandblack.com
联系我们。
有关Bit&Black的更多信息,请访问www.bitandblack.com。