soapbox / css-colors
一个接收颜色十六进制值并返回可能的文本颜色和背景颜色变化的包。非常适合创建CSS渐变和动态确定文本颜色。
1.0
2014-07-17 19:33 UTC
Requires
- php: >=5.3.0
- illuminate/http: ~4.1
- illuminate/support: ~4.1
- illuminate/validation: ~4.1
This package is auto-updated.
Last update: 2024-09-17 07:56:58 UTC
README
接收十六进制颜色并生成该颜色的前景和背景变体
它采用了由Patrick Fitzgerald在2004年创建的优秀的PHP类(http://www.barelyfitz.com/projects/csscolor/)并将其封装成一个库,以便在你的项目中使用。
安装
通过Composer安装此包。将以下内容添加到你的composer.json文件中
"require": { "soapbox/css-colors": "dev-master" }
然后,运行composer install
最后,将服务提供者和外观添加到app/config/app.php中。
'providers' => array( // ... 'SoapBox\Csscolor\CsscolorServiceProvider' ) Not required, but you can addd the Csscolor alias if you want. 'aliases' => array( // ... 'Csscolor' => 'SoapBox\Csscolor\Facade' )
使用方法
你只需要将HEX值放入颜色对象中
$color = Csscolor::make('3D88C8'); $color->bg['0']; // returns the same colour as entered $color->bg['+1']; // +1 to +5 and -1 to -5 to return variations of the colour to work with gradiants $color->fg['0']; // returns a colour that can sit on the foreground of the defined hex value ...
使用颜色#3D88C8实例化的$color对象的var_dump输出如下
object(SoapBox\Csscolor\Csscolor)[1109] public 'bg' => array (size=11) 0 => string '3D88C8' (length=6) '+1' => string '5a9ad0' (length=6) '+2' => string '6ea6d6' (length=6) '+3' => string '9fc4e4' (length=6) '+4' => string 'cee1f1' (length=6) '+5' => string 'ecf4fa' (length=6) -1 => string '3474aa' (length=6) -2 => string '2e6696' (length=6) -3 => string '1f4464' (length=6) -4 => string '0f2232' (length=6) -5 => string '060e14' (length=6) public 'fg' => array (size=11) 0 => string 'ffffff' (length=6) '+1' => string '000000' (length=6) '+2' => string '000000' (length=6) '+3' => string '000000' (length=6) '+4' => string '0f2232' (length=6) '+5' => string '1f4464' (length=6) -1 => string 'ffffff' (length=6) -2 => string 'ffffff' (length=6) -3 => string 'ffffff' (length=6) -4 => string 'cee1f1' (length=6) -5 => string '9fc4e4' (length=6) public 'minBrightDiff' => int 126 public 'minColorDiff' => int 500