lasserafn/php-hexer
Composer 安装命令:
composer require lasserafn/php-hexer
包简介
A package to adjust brightness from a hex colorcode
关键字:
README 文档
README
Ever wanted to lighten or darken a hex in PHP? This package will allow you to. It's easy to use, fully tested and is very lightweight.
+ Added the ability to convert to RGB
Installation
You just require using composer and you're good to go!
composer require lasserafn/php-hexer
Usage
As with installation, usage is quite simple.
use LasseRafn\Hexer\Hex; // Lighten $hex = new Hex('#333'); // You can leave out the hashtag if you wish. echo $hex->lighten(15); // Output: #595959 (if you left out the hashtag, it would not be included in the output either) // Darken $hex = new Hex('ffffff'); echo $hex->darken(15); // Output: d9d9d9 // To RGB $hex = new Hex('007F00'); $hex->lighten(50)->toRgb(); // Returns: ['r' => 128, 'g' => 255, 'b' => 128]
Methods
The constructor accepts one parameter (hex) which can optionally contain a hashtag (#). The length has to be between 3-6 characters (without the hashtag).
lighten($percentage)
Will lighten the color by X percentage. Percentage must be between 0-100. An exception will be thrown otherwise.
darken($percentage)
Will darken the color by X percentage. Percentage must be between 0-100. An exception will be thrown otherwise.
toRgb()
Will return the hex as RGB (an array of r, g, b).
Exceptions
If you input a HEX which is less than 3 characters of length, or greater than 6, an exception will be thrown. Similar with percentages, if you specify a percentage less than zero, or greater than 100, an exception will be thrown. If the percentage is zero, the hex itself will simply be returned.
Requirements
- PHP 5.6, 7.0 or 7.1
lasserafn/php-hexer 适用场景与选型建议
lasserafn/php-hexer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.23k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2017 年 06 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「color」 「hex」 「Brightness」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 lasserafn/php-hexer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lasserafn/php-hexer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 lasserafn/php-hexer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Working with colors
Collection of useful debugging utilities
Native (browser) color input field for SilverStripe
The PHP Average Color Picker Library
Colorizes the Flarum forum header and interface based on the active tag's color.
A modern PHP library for converting color codes between RGB, HEX, and HSL color spaces.
统计信息
- 总下载量: 1.23k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-06-16