Documentation

Color
in package

Console color class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
4.1.0

Table of Contents

Constants

BLACK  = 1
BLUE  = 5
BOLD_BLACK  = 17
BOLD_BLUE  = 21
BOLD_CYAN  = 23
BOLD_GREEN  = 19
BOLD_MAGENTA  = 22
BOLD_RED  = 18
BOLD_WHITE  = 24
BOLD_YELLOW  = 20
BRIGHT_BLACK  = 9
BRIGHT_BLUE  = 13
BRIGHT_BOLD_BLACK  = 25
BRIGHT_BOLD_BLUE  = 29
BRIGHT_BOLD_CYAN  = 31
BRIGHT_BOLD_GREEN  = 27
BRIGHT_BOLD_MAGENTA  = 30
BRIGHT_BOLD_RED  = 26
BRIGHT_BOLD_WHITE  = 32
BRIGHT_BOLD_YELLOW  = 28
BRIGHT_CYAN  = 15
BRIGHT_GREEN  = 11
BRIGHT_MAGENTA  = 14
BRIGHT_RED  = 10
BRIGHT_WHITE  = 16
BRIGHT_YELLOW  = 12
CYAN  = 7
GREEN  = 3
MAGENTA  = 6
NORMAL  = 0
Color indices
RED  = 2
WHITE  = 8
YELLOW  = 4

Properties

$bgColorMap  : array<string|int, mixed>
Color map of background color ansi values
$fgColorMap  : array<string|int, mixed>
Color map of foreground ansi values

Methods

colorize()  : string
Colorize a string for output
getBgColorCode()  : mixed
Get the background color code from the color map
getFgColorCode()  : mixed
Get the foreground color code from the color map

Constants

BLACK

public mixed BLACK = 1

BOLD_BLACK

public mixed BOLD_BLACK = 17

BOLD_BLUE

public mixed BOLD_BLUE = 21

BOLD_CYAN

public mixed BOLD_CYAN = 23

BOLD_GREEN

public mixed BOLD_GREEN = 19

BOLD_MAGENTA

public mixed BOLD_MAGENTA = 22

BOLD_RED

public mixed BOLD_RED = 18

BOLD_WHITE

public mixed BOLD_WHITE = 24

BOLD_YELLOW

public mixed BOLD_YELLOW = 20

BRIGHT_BLACK

public mixed BRIGHT_BLACK = 9

BRIGHT_BLUE

public mixed BRIGHT_BLUE = 13

BRIGHT_BOLD_BLACK

public mixed BRIGHT_BOLD_BLACK = 25

BRIGHT_BOLD_BLUE

public mixed BRIGHT_BOLD_BLUE = 29

BRIGHT_BOLD_CYAN

public mixed BRIGHT_BOLD_CYAN = 31

BRIGHT_BOLD_GREEN

public mixed BRIGHT_BOLD_GREEN = 27

BRIGHT_BOLD_MAGENTA

public mixed BRIGHT_BOLD_MAGENTA = 30

BRIGHT_BOLD_RED

public mixed BRIGHT_BOLD_RED = 26

BRIGHT_BOLD_WHITE

public mixed BRIGHT_BOLD_WHITE = 32

BRIGHT_BOLD_YELLOW

public mixed BRIGHT_BOLD_YELLOW = 28

BRIGHT_CYAN

public mixed BRIGHT_CYAN = 15

BRIGHT_GREEN

public mixed BRIGHT_GREEN = 11

BRIGHT_MAGENTA

public mixed BRIGHT_MAGENTA = 14

BRIGHT_RED

public mixed BRIGHT_RED = 10

BRIGHT_WHITE

public mixed BRIGHT_WHITE = 16

BRIGHT_YELLOW

public mixed BRIGHT_YELLOW = 12

GREEN

public mixed GREEN = 3

MAGENTA

public mixed MAGENTA = 6

NORMAL

Color indices

public mixed NORMAL = 0

WHITE

public mixed WHITE = 8

YELLOW

public mixed YELLOW = 4

Properties

$bgColorMap

Color map of background color ansi values

protected static array<string|int, mixed> $bgColorMap = [self::NORMAL => '0;49', self::BLACK => '40', self::RED => '41', self::GREEN => '42', self::YELLOW => '43', self::BLUE => '44', self::MAGENTA => '45', self::CYAN => '46', self::WHITE => '47', self::BRIGHT_BLACK => '100', self::BRIGHT_RED => '101', self::BRIGHT_GREEN => '102', self::BRIGHT_YELLOW => '103', self::BRIGHT_BLUE => '104', self::BRIGHT_MAGENTA => '105', self::BRIGHT_CYAN => '106', self::BRIGHT_WHITE => '107']

$fgColorMap

Color map of foreground ansi values

protected static array<string|int, mixed> $fgColorMap = [self::NORMAL => '22;39', self::BLACK => '0;30', self::RED => '0;31', self::GREEN => '0;32', self::YELLOW => '0;33', self::BLUE => '0;34', self::MAGENTA => '0;35', self::CYAN => '0;36', self::WHITE => '0;37', self::BRIGHT_BLACK => '0;90', self::BRIGHT_RED => '0;91', self::BRIGHT_GREEN => '0;92', self::BRIGHT_YELLOW => '0;93', self::BRIGHT_BLUE => '0;94', self::BRIGHT_MAGENTA => '0;95', self::BRIGHT_CYAN => '0;96', self::BRIGHT_WHITE => '0;97', self::BOLD_BLACK => '1;30', self::BOLD_RED => '1;31', self::BOLD_GREEN => '1;32', self::BOLD_YELLOW => '1;33', self::BOLD_BLUE => '1;34', self::BOLD_MAGENTA => '1;35', self::BOLD_CYAN => '1;36', self::BOLD_WHITE => '1;37', self::BRIGHT_BOLD_BLACK => '1;90', self::BRIGHT_BOLD_RED => '1;91', self::BRIGHT_BOLD_GREEN => '1;92', self::BRIGHT_BOLD_YELLOW => '1;93', self::BRIGHT_BOLD_BLUE => '1;94', self::BRIGHT_BOLD_MAGENTA => '1;95', self::BRIGHT_BOLD_CYAN => '1;96', self::BRIGHT_BOLD_WHITE => '1;97']

Methods

colorize()

Colorize a string for output

public static colorize(string $string[, int|null $fg = null ][, int|null $bg = null ][, bool $raw = false ]) : string
Parameters
$string : string
$fg : int|null = null
$bg : int|null = null
$raw : bool = false
Return values
string

getBgColorCode()

Get the background color code from the color map

public static getBgColorCode([int|null $color = null ]) : mixed
Parameters
$color : int|null = null

getFgColorCode()

Get the foreground color code from the color map

public static getFgColorCode([int|null $color = null ]) : mixed
Parameters
$color : int|null = null

        
On this page

Search results