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