dragon-code/which-color 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dragon-code/which-color

最新稳定版本:4.1.0

Composer 安装命令:

composer require dragon-code/which-color

包简介

A simple helper, helping to determine what color the text will look better over a monotonous color.

README 文档

README

Which Color

A simple helper, helping to determine what color the text will look better over a monotonous color.

Stable Version Total Downloads Github Workflow Status License

Installation

To get the latest version of package, simply require the project using Composer:

composer require dragon-code/which-color

Instead, you may of course manually update your require section and run composer update if you so choose:

{
    "require": {
        "dragon-code/which-color": "^4.0"
    }
}

Using

The package helps to determine what color it is better to write text over a monotonous color.

use DragonCode\WhichColor\Facades\Color;

return Color::of('#000000')->lightIsBetter(); // returned `true`. A white text color is better for black background.
return Color::of('#ffffff')->darkIsBetter(); // returned `true`. A black text color is better for white background.

return Color::of('#ffffff')->lightIsBetter(); // returned `false`. White color is not the best for white background.
return Color::of('#000000')->darkIsBetter(); // returned `false`. Black color is not the best for black background.

You can also use the converter:

use DragonCode\WhichColor\Services\Converter;

$converted = new Converter();

$rgb = $converted->hex2rgb('#fa000a'); // RGB object with [250, 0, 10]
// $rgb->red; // 250
// $rgb->green; // 0
// $rgb->blue; // 10
// $rgb->toArray(); // [250, 0, 10]

$converted->hex2rgb('#f5a'); // RGB object with [255, 85, 170]
$converted->hex2rgb('#ff55aa'); // RGB object with [255, 85, 170]

$converted->rgb2hex($rgb); // '#fa000a'
$converted->rgb2hex([250, 0, 10]); // '#fa000a'
$converted->rgb2hex(['red' => 250, 'green' => 0, 'blue' => 10]); // '#fa000a'
$converted->rgb2hex(['r' => 250, 'g' => 0, 'b' => 10]); // '#fa000a'

Example

map of colors

License

This package is licensed under the MIT License.

统计信息

  • 总下载量: 7.15k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-12-19