ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilSystemStyleIconColor Class Reference
+ Collaboration diagram for ilSystemStyleIconColor:

Public Member Functions

 __construct ($id, $name, $color, $description="")
 ilSystemStyleIconColor constructor. More...
 
 getId ()
 
 setId ($id)
 
 getColor ()
 
 setColor ($color)
 
 getName ()
 
 setName ($name)
 
 getDescription ()
 
 setDescription ($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

 $id = ""
 
 $color = ""
 
 $name = ""
 
 $description = ""
 
 $brightness = null
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

Member Function Documentation

◆ compareColors()

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

Used to sort colors according to their brightness.

Parameters
ilSystemStyleIconColor$color1
ilSystemStyleIconColor$color2
Returns
int

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

222 {
223 $value1 = $color1->getPerceivedBrightness();
224 $value2 = $color2->getPerceivedBrightness();
225
226 if ($value1 == $value2) {
227 return 0;
228 }
229 return ($value1 > $value2) ? +1 : -1;
230 }
getPerceivedBrightness()
Used to sort the colors according to their brightness.

References getPerceivedBrightness().

Referenced by ilSystemStyleIconColorTest\testCompareColors().

+ 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.

Returns
number

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

187 {
188 return hexdec(substr($this->getColor(), 4, 2));
189 }

References getColor().

Referenced by getDominatAspect(), and getPerceivedBrightness().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColor()

ilSystemStyleIconColor::getColor ( )
Returns
string

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

88 {
89 return $this->color;
90 }

References $color.

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

+ Here is the caller graph for this function:

◆ getDescription()

ilSystemStyleIconColor::getDescription ( )
Returns
string

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

127 {
128 return $this->description;
129 }

References $description.

◆ 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.

Returns
int

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

145 {
146 $r = $this->getRedAspect();
147 $g = $this->getGreenAspect();
148 $b = $this->getBlueAspect();
149
150 if ($r == $g && $r == $b && $g == $b) {
151 return self::GREY;
152 } elseif ($r > $g && $r > $b) {
153 return self::RED;
154 } elseif ($g > $r && $g > $b) {
155 return self::GREEN;
156 } else {
157 return self::BLUE;
158 }
159 }
getBlueAspect()
Get blue aspect from a color in hex format.
getGreenAspect()
Get green aspect from a color in hex format.
getRedAspect()
Get red aspect from a color in hex format.
$r
Definition: example_031.php:79

References $r, BLUE, getBlueAspect(), getGreenAspect(), getRedAspect(), GREEN, GREY, and RED.

+ Here is the call graph for this function:

◆ getGreenAspect()

ilSystemStyleIconColor::getGreenAspect ( )

Get green aspect from a color in hex format.

Returns
number

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

177 {
178 return hexdec(substr($this->getColor(), 2, 2));
179 }

References getColor().

Referenced by getDominatAspect(), and getPerceivedBrightness().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilSystemStyleIconColor::getId ( )
Returns
string

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

72 {
73 return $this->id;
74 }

References $id.

Referenced by ilSystemStyleIconColorSet\addColor().

+ Here is the caller graph for this function:

◆ getName()

ilSystemStyleIconColor::getName ( )
Returns
string

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

111 {
112 return $this->name;
113 }

References $name.

◆ 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

Returns
float|null

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

199 {
200 if ($this->brightness === null) {
201 $r = $this->getRedAspect();
202 $g = $this->getGreenAspect();
203 $b = $this->getBlueAspect();
204
205 $this->brightness = sqrt(
206 $r * $r * .299 +
207 $g * $g * .587 +
208 $b * $b * .114
209 );
210 }
211 return $this->brightness;
212 }

References $brightness, $r, getBlueAspect(), getGreenAspect(), and getRedAspect().

Referenced by compareColors().

+ 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.

Returns
number

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

167 {
168 return hexdec(substr($this->getColor(), 0, 2));
169 }

References getColor().

Referenced by getDominatAspect(), and getPerceivedBrightness().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setColor()

ilSystemStyleIconColor::setColor (   $color)
Parameters
$color
Exceptions
ilSystemStyleColorException

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

97 {
98 $color = strtoupper($color);
99
100 if (!ctype_xdigit($color) || strlen($color) != 6) {
102 }
103
104 $this->color = $color;
105 }
Class for advanced editing exception handling in ILIAS.
if(PHP_SAPI !='cli') color
Definition: langcheck.php:120

References $color, color, and ilSystemStyleColorException\INVALID_COLOR_EXCEPTION.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setDescription()

ilSystemStyleIconColor::setDescription (   $description)
Parameters
string$description

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

135 {
136 $this->description = $description;
137 }

References $description.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setId()

ilSystemStyleIconColor::setId (   $id)
Parameters
string$id

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

80 {
81 $this->id = $id;
82 }

References $id.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setName()

ilSystemStyleIconColor::setName (   $name)
Parameters
string$name

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

119 {
120 $this->name = $name;
121 }

References $name.

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $brightness

ilSystemStyleIconColor::$brightness = null
protected

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

Referenced by getPerceivedBrightness().

◆ $color

ilSystemStyleIconColor::$color = ""
protected

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

Referenced by __construct(), getColor(), and setColor().

◆ $description

ilSystemStyleIconColor::$description = ""
protected

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

Referenced by __construct(), getDescription(), and setDescription().

◆ $id

ilSystemStyleIconColor::$id = ""
protected

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

Referenced by __construct(), getId(), and setId().

◆ $name

ilSystemStyleIconColor::$name = ""
protected

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

Referenced by __construct(), getName(), and setName().

◆ BLUE

◆ GREEN

◆ GREY

◆ RED


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