mistic100/randomcolor
Composer 安装命令:
composer require mistic100/randomcolor
包简介
Generate attractive random colors
关键字:
README 文档
README
For generating attractive random colors.
This is a PHP port of David Merfield randomColor Javascript utility.
See the results on the demo.
Options
You can pass an options object to influence the type of color it produces. The options object accepts the following properties:
hue – Controls the hue of the generated color. You can pass a string representing a color name (e.g. 'orange'). Possible color names are red, orange, yellow, green, blue, purple, pink and monochrome. You can also pass an array of multiple hues or a specific hue (0 to 360).
luminosity – Controls the luminosity of the generated color. You can pass a string containing bright, light or dark.
alpha – A decimal between 0 and 1. Only relevant when using a format with an alpha channel. Defaults to a random value.
format – A string which specifies the format of the generated color. Possible values are hsv, hsl, hslCss, rgb, rgbCss, hex and their alpha variants hsva, hsla, hlsaCss, rgba, rgbaCss, hexa. Defaults to hex.
prng – A random (or not) number generator. mt_rand is used as default one.
Examples
use \Colors\RandomColor; // Returns a hex code for an attractive color RandomColor::one(); // Returns an array of ten green colors RandomColor::many(10, array( 'hue' => 'green', )); // Returns a hex code for a light blue RandomColor::one(array( 'luminosity' => 'light', 'hue' => 'blue', )); // Returns one yellow or blue color RandomColors::one(array( 'hue' => array('yellow', 'blue'), )); // Returns a hex code for a 'truly random' color RandomColor::one(array( 'luminosity' => 'random', 'hue' => 'random', )); // Returns a bright color in RGB RandomColor::one(array( 'luminosity' => 'bright', 'format' => 'rgbCss', // e.g. 'rgb(225,200,20)' )); // Returns a RGB color with random alpha RandomColor::one(array( 'format': 'rgbaCss', // e.g. 'rgba(9, 1, 107, 0.648)' )); // Returns an hex color with specified alpha RandomColor::one(array( 'format': 'hexa', 'alpha': 0.5, // e.g.: #c17d3480 ));
Other languages
RandomColor is available in JavaScript, C#, C++, Go, Haskell, Kotlin, Mathematica, Python, Swift, Perl6, Objective-C, Java, R, Reason, Dart, Ruby, Rust and Swift.
License
This project is licensed under the terms of the MIT license.
mistic100/randomcolor 适用场景与选型建议
mistic100/randomcolor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.55M 次下载、GitHub Stars 达 241, 最近一次更新时间为 2014 年 12 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「color」 「random」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mistic100/randomcolor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mistic100/randomcolor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mistic100/randomcolor 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Native (browser) color input field for SilverStripe
Colorizes the Flarum forum header and interface based on the active tag's color.
Faker Japanese is a Faker provider that generates fake Japanese related data for you.
Gambling Algorithms for Certification.
Color conversion library
统计信息
- 总下载量: 1.55M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 245
- 点击次数: 21
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-10
