ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ColorMap.php
Go to the documentation of this file.
1<?php
2
4
6
8{
12 private static $colorMap = [
13 '#000000' => 0x08,
14 '#FFFFFF' => 0x09,
15 '#FF0000' => 0x0A,
16 '#00FF00' => 0x0B,
17 '#0000FF' => 0x0C,
18 '#FFFF00' => 0x0D,
19 '#FF00FF' => 0x0E,
20 '#00FFFF' => 0x0F,
21 '#800000' => 0x10,
22 '#008000' => 0x11,
23 '#000080' => 0x12,
24 '#808000' => 0x13,
25 '#800080' => 0x14,
26 '#008080' => 0x15,
27 '#C0C0C0' => 0x16,
28 '#808080' => 0x17,
29 '#9999FF' => 0x18,
30 '#993366' => 0x19,
31 '#FFFFCC' => 0x1A,
32 '#CCFFFF' => 0x1B,
33 '#660066' => 0x1C,
34 '#FF8080' => 0x1D,
35 '#0066CC' => 0x1E,
36 '#CCCCFF' => 0x1F,
37 // '#000080' => 0x20,
38 // '#FF00FF' => 0x21,
39 // '#FFFF00' => 0x22,
40 // '#00FFFF' => 0x23,
41 // '#800080' => 0x24,
42 // '#800000' => 0x25,
43 // '#008080' => 0x26,
44 // '#0000FF' => 0x27,
45 '#00CCFF' => 0x28,
46 // '#CCFFFF' => 0x29,
47 '#CCFFCC' => 0x2A,
48 '#FFFF99' => 0x2B,
49 '#99CCFF' => 0x2C,
50 '#FF99CC' => 0x2D,
51 '#CC99FF' => 0x2E,
52 '#FFCC99' => 0x2F,
53 '#3366FF' => 0x30,
54 '#33CCCC' => 0x31,
55 '#99CC00' => 0x32,
56 '#FFCC00' => 0x33,
57 '#FF9900' => 0x34,
58 '#FF6600' => 0x35,
59 '#666699' => 0x36,
60 '#969696' => 0x37,
61 '#003366' => 0x38,
62 '#339966' => 0x39,
63 '#003300' => 0x3A,
64 '#333300' => 0x3B,
65 '#993300' => 0x3C,
66 // '#993366' => 0x3D,
67 '#333399' => 0x3E,
68 '#333333' => 0x3F,
69 ];
70
71 public static function lookup(Color $color, int $defaultIndex = 0x00): int
72 {
73 $colorRgb = $color->getRGB();
74 if (is_string($colorRgb) && array_key_exists("#{$colorRgb}", self::$colorMap)) {
75 return self::$colorMap["#{$colorRgb}"];
76 }
77
78// TODO Try and map RGB value to nearest colour within the define pallette
79// $red = Color::getRed($colorRgb, false);
80// $green = Color::getGreen($colorRgb, false);
81// $blue = Color::getBlue($colorRgb, false);
82
83// $paletteSpace = 3;
84// $newColor = ($red * $paletteSpace / 256) * ($paletteSpace * $paletteSpace) +
85// ($green * $paletteSpace / 256) * $paletteSpace +
86// ($blue * $paletteSpace / 256);
87
88 return $defaultIndex;
89 }
90}
An exception for terminatinating execution or to throw for unit testing.
static lookup(Color $color, int $defaultIndex=0x00)
Definition: ColorMap.php:71