cdoco/ansi-styles
Composer 安装命令:
composer require cdoco/ansi-styles
包简介
ANSI escape codes for styling strings in the terminal
关键字:
README 文档
README
ANSI escape codes for styling strings in the terminal
Install
$ composer require cdoco/ansi-styles
Usage
require_once 'vendor/autoload.php'; $style = new \Cdoco\AnsiStyles(); echo $style->blue->open . 'Hello Word!' . PHP_EOL . $style->blue->close; echo $style->color->rgb(100, 200, 15) . "Hello Word!" . PHP_EOL . $style->color->close; echo $style->color->hsl(120, 100, 60) . "Hello Word!" . PHP_EOL . $style->color->close; echo $style->color->hex('#C0FFEE') . "Hello Word!" . PHP_EOL . $style->color->close; echo $style->bgColor->rgb(100, 200, 15) . "Hello Word!" . PHP_EOL . $style->bgColor->close;
API
Each style has an open and close property.
Styles
Modifiers
resetbolddimitalic(Not widely supported)underlineinversehiddenstrikethrough(Not widely supported)
Colors
blackredgreenyellowbluemagentacyanwhitegray("bright black")redBrightgreenBrightyellowBrightblueBrightmagentaBrightcyanBrightwhiteBright
Background colors
bgBlackbgRedbgGreenbgYellowbgBluebgMagentabgCyanbgWhitebgBlackBrightbgRedBrightbgGreenBrightbgYellowBrightbgBlueBrightbgMagentaBrightbgCyanBrightbgWhiteBright
Advanced usage
By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
$style->modifier$style->color$style->bgColor
Example
echo $style->color->green->open;
256 / 16 million (TrueColor) support
To use these, call the associated conversion function with the intended output, for example:
$style->color->rgb(100, 200, 15); // RGB to 16 color ansi foreground code $style->bgColor->rgb(100, 200, 15); // RGB to 16 color ansi background code $style->color->hsl(120, 100, 60); // HSL to 256 color ansi foreground code $style->bgColor->hsl(120, 100, 60); // HSL to 256 color ansi foreground code $style->color->hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code $style->bgColor->hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
License
MIT
统计信息
- 总下载量: 102
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2017-11-15
