ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSystemStyleIconColor Class Reference
+ Collaboration diagram for ilSystemStyleIconColor:

Public Member Functions

 __construct (string $id, string $name, string $color, string $description='')
 ilSystemStyleIconColor constructor. More...
 
 getId ()
 
 setId (string $id)
 
 getColor ()
 
 setColor (string $color)
 
 getName ()
 
 setName (string $name)
 
 getDescription ()
 
 setDescription (string $description)
 
 getDominatAspect ()
 Used to order the colors according to their dominant aspect. More...
 
 getRedAspect ()
 Get red aspect from a color in hex format. More...
 
 getGreenAspect ()
 Get green aspect from a color in hex format. More...
 
 getBlueAspect ()
 Get blue aspect from a color in hex format. More...
 
 getPerceivedBrightness ()
 Used to sort the colors according to their brightness. More...
 

Static Public Member Functions

static compareColors (ilSystemStyleIconColor $color1, ilSystemStyleIconColor $color2)
 Used to sort colors according to their brightness. More...
 

Data Fields

const GREY = 0
 
const RED = 1
 
const GREEN = 2
 
const BLUE = 3
 

Protected Attributes

string $id = ''
 Unique ID to identify the color by (currently same as color) More...
 
string $color = ''
 Value of the color. More...
 
string $name = ''
 Name of the color in text. More...
 
string $description = ''
 Description of the color. More...
 

Detailed Description

Definition at line 24 of file class.ilSystemStyleIconColor.php.

Constructor & Destructor Documentation

◆ __construct()

ilSystemStyleIconColor::__construct ( string  $id,
string  $name,
string  $color,
string  $description = '' 
)

ilSystemStyleIconColor constructor.

Definition at line 54 of file class.ilSystemStyleIconColor.php.

References setColor(), setDescription(), setId(), and setName().

55  {
56  $this->setId($id);
57  $this->setColor($color);
58  $this->setName($name);
60  }
string $id
Unique ID to identify the color by (currently same as color)
string $description
Description of the color.
string $color
Value of the color.
string $name
Name of the color in text.
+ Here is the call graph for this function:

Member Function Documentation

◆ compareColors()

static ilSystemStyleIconColor::compareColors ( ilSystemStyleIconColor  $color1,
ilSystemStyleIconColor  $color2 
)
static

Used to sort colors according to their brightness.

Definition at line 177 of file class.ilSystemStyleIconColor.php.

References getPerceivedBrightness().

Referenced by ilSystemStyleIconColorTest\testCompareColors().

177  : int
178  {
179  $value1 = $color1->getPerceivedBrightness();
180  $value2 = $color2->getPerceivedBrightness();
181 
182  if ($value1 == $value2) {
183  return 0;
184  }
185  return ($value1 > $value2) ? +1 : -1;
186  }
getPerceivedBrightness()
Used to sort the colors according to their brightness.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBlueAspect()

ilSystemStyleIconColor::getBlueAspect ( )

Get blue aspect from a color in hex format.

Definition at line 151 of file class.ilSystemStyleIconColor.php.

References getColor().

Referenced by getDominatAspect(), and getPerceivedBrightness().

151  : int
152  {
153  return hexdec(substr($this->getColor(), 4, 2));
154  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColor()

ilSystemStyleIconColor::getColor ( )

Definition at line 72 of file class.ilSystemStyleIconColor.php.

References $color.

Referenced by getBlueAspect(), getGreenAspect(), and getRedAspect().

72  : string
73  {
74  return $this->color;
75  }
string $color
Value of the color.
+ Here is the caller graph for this function:

◆ getDescription()

ilSystemStyleIconColor::getDescription ( )

Definition at line 101 of file class.ilSystemStyleIconColor.php.

References $description.

101  : string
102  {
103  return $this->description;
104  }
string $description
Description of the color.

◆ getDominatAspect()

ilSystemStyleIconColor::getDominatAspect ( )

Used to order the colors according to their dominant aspect.

Due to the vast numbers of colors to be displayed to the user, they must be ordered in some fashion, dominant aspect and brightness are possible values.

Definition at line 115 of file class.ilSystemStyleIconColor.php.

References Vendor\Package\$b, getBlueAspect(), getGreenAspect(), and getRedAspect().

115  : int
116  {
117  $r = $this->getRedAspect();
118  $g = $this->getGreenAspect();
119  $b = $this->getBlueAspect();
120 
121  if ($r == $g && $r == $b && $g == $b) {
122  return self::GREY;
123  } elseif ($r > $g && $r > $b) {
124  return self::RED;
125  } elseif ($g > $r && $g > $b) {
126  return self::GREEN;
127  } else {
128  return self::BLUE;
129  }
130  }
getBlueAspect()
Get blue aspect from a color in hex format.
getRedAspect()
Get red aspect from a color in hex format.
getGreenAspect()
Get green aspect from a color in hex format.
+ Here is the call graph for this function:

◆ getGreenAspect()

ilSystemStyleIconColor::getGreenAspect ( )

Get green aspect from a color in hex format.

Definition at line 143 of file class.ilSystemStyleIconColor.php.

References getColor().

Referenced by getDominatAspect(), and getPerceivedBrightness().

143  : int
144  {
145  return hexdec(substr($this->getColor(), 2, 2));
146  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilSystemStyleIconColor::getId ( )

Definition at line 62 of file class.ilSystemStyleIconColor.php.

References $id.

Referenced by ilSystemStyleIconColorSet\addColor().

62  : string
63  {
64  return $this->id;
65  }
string $id
Unique ID to identify the color by (currently same as color)
+ Here is the caller graph for this function:

◆ getName()

ilSystemStyleIconColor::getName ( )

Definition at line 91 of file class.ilSystemStyleIconColor.php.

References $name.

91  : string
92  {
93  return $this->name;
94  }
string $name
Name of the color in text.

◆ getPerceivedBrightness()

ilSystemStyleIconColor::getPerceivedBrightness ( )

Used to sort the colors according to their brightness.

Due to the vast numbers of colors to be displayed to the user, they must be ordered in some fashion, dominant aspect and brightness are possible values. See: https://en.wikipedia.org/wiki/YIQ

Definition at line 161 of file class.ilSystemStyleIconColor.php.

References Vendor\Package\$b, getBlueAspect(), getGreenAspect(), and getRedAspect().

Referenced by compareColors().

161  : float
162  {
163  $r = $this->getRedAspect();
164  $g = $this->getGreenAspect();
165  $b = $this->getBlueAspect();
166 
167  return sqrt(
168  $r * $r * .299 +
169  $g * $g * .587 +
170  $b * $b * .114
171  );
172  }
getBlueAspect()
Get blue aspect from a color in hex format.
getRedAspect()
Get red aspect from a color in hex format.
getGreenAspect()
Get green aspect from a color in hex format.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRedAspect()

ilSystemStyleIconColor::getRedAspect ( )

Get red aspect from a color in hex format.

Definition at line 135 of file class.ilSystemStyleIconColor.php.

References getColor().

Referenced by getDominatAspect(), and getPerceivedBrightness().

135  : int
136  {
137  return hexdec(substr($this->getColor(), 0, 2));
138  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setColor()

ilSystemStyleIconColor::setColor ( string  $color)
Exceptions
ilSystemStyleColorException

Definition at line 80 of file class.ilSystemStyleIconColor.php.

References $color, and ilSystemStyleColorException\INVALID_COLOR_EXCEPTION.

Referenced by __construct().

80  : void
81  {
82  $color = strtoupper($color);
83 
84  if (!ctype_xdigit($color) || (strlen($color) != 6 && strlen($color) != 3)) {
86  }
87 
88  $this->color = $color;
89  }
Class for advanced editing exception handling in ILIAS.
string $color
Value of the color.
+ Here is the caller graph for this function:

◆ setDescription()

ilSystemStyleIconColor::setDescription ( string  $description)

Definition at line 106 of file class.ilSystemStyleIconColor.php.

References $description.

Referenced by __construct().

106  : void
107  {
108  $this->description = $description;
109  }
string $description
Description of the color.
+ Here is the caller graph for this function:

◆ setId()

ilSystemStyleIconColor::setId ( string  $id)

Definition at line 67 of file class.ilSystemStyleIconColor.php.

References $id.

Referenced by __construct().

67  : void
68  {
69  $this->id = $id;
70  }
string $id
Unique ID to identify the color by (currently same as color)
+ Here is the caller graph for this function:

◆ setName()

ilSystemStyleIconColor::setName ( string  $name)

Definition at line 96 of file class.ilSystemStyleIconColor.php.

References $name.

Referenced by __construct().

96  : void
97  {
98  $this->name = $name;
99  }
string $name
Name of the color in text.
+ Here is the caller graph for this function:

Field Documentation

◆ $color

string ilSystemStyleIconColor::$color = ''
protected

Value of the color.

Definition at line 39 of file class.ilSystemStyleIconColor.php.

Referenced by getColor(), and setColor().

◆ $description

string ilSystemStyleIconColor::$description = ''
protected

Description of the color.

Definition at line 49 of file class.ilSystemStyleIconColor.php.

Referenced by getDescription(), and setDescription().

◆ $id

string ilSystemStyleIconColor::$id = ''
protected

Unique ID to identify the color by (currently same as color)

Definition at line 34 of file class.ilSystemStyleIconColor.php.

Referenced by getId(), and setId().

◆ $name

string ilSystemStyleIconColor::$name = ''
protected

Name of the color in text.

Definition at line 44 of file class.ilSystemStyleIconColor.php.

Referenced by getName(), and setName().

◆ BLUE

◆ GREEN

◆ GREY

◆ RED


The documentation for this class was generated from the following file: