1 | <?php |
||
11 | class Color |
||
12 | { |
||
13 | /** Standard colors - based on Office Online */ |
||
14 | const BLACK = '000000'; |
||
15 | const WHITE = 'FFFFFF'; |
||
16 | const RED = 'FF0000'; |
||
17 | const DARK_RED = 'C00000'; |
||
18 | const ORANGE = 'FFC000'; |
||
19 | const YELLOW = 'FFFF00'; |
||
20 | const LIGHT_GREEN = '92D040'; |
||
21 | const GREEN = '00B050'; |
||
22 | const LIGHT_BLUE = '00B0E0'; |
||
23 | const BLUE = '0070C0'; |
||
24 | const DARK_BLUE = '002060'; |
||
25 | const PURPLE = '7030A0'; |
||
26 | |||
27 | /** |
||
28 | * Returns an RGB color from R, G and B values |
||
29 | * |
||
30 | * @param int $red Red component, 0 - 255 |
||
31 | * @param int $green Green component, 0 - 255 |
||
32 | * @param int $blue Blue component, 0 - 255 |
||
33 | * @return string RGB color |
||
34 | */ |
||
35 | 34 | public static function rgb($red, $green, $blue) |
|
47 | |||
48 | /** |
||
49 | * Throws an exception is the color component value is outside of bounds (0 - 255) |
||
50 | * |
||
51 | * @param int $colorComponent |
||
52 | * @throws \Box\Spout\Common\Exception\InvalidColorException |
||
53 | * @return void |
||
54 | */ |
||
55 | 34 | protected static function throwIfInvalidColorComponentValue($colorComponent) |
|
61 | |||
62 | /** |
||
63 | * Converts the color component to its corresponding hexadecimal value |
||
64 | * |
||
65 | * @param int $colorComponent Color component, 0 - 255 |
||
66 | * @return string Corresponding hexadecimal value, with a leading 0 if needed. E.g "0f", "2d" |
||
67 | */ |
||
68 | 19 | protected static function convertColorComponentToHex($colorComponent) |
|
72 | |||
73 | /** |
||
74 | * Returns the ARGB color of the given RGB color, |
||
75 | * assuming that alpha value is always 1. |
||
76 | * |
||
77 | * @param string $rgbColor RGB color like "FF08B2" |
||
78 | * @return string ARGB color |
||
79 | */ |
||
80 | 36 | public static function toARGB($rgbColor) |
|
84 | } |
||
85 |