ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 215 of file class.ilSystemStyleIconColor.php.

References getPerceivedBrightness().

Referenced by ilSystemStyleIconColorTest\testCompareColors().

215  {
216  $value1 = $color1->getPerceivedBrightness();
217  $value2 = $color2->getPerceivedBrightness();
218 
219  if ($value1 == $value2) {
220  return 0;
221  }
222  return ($value1 > $value2) ? +1 : -1;
223  }
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.

Returns
number

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

References getColor().

Referenced by getDominatAspect(), and getPerceivedBrightness().

183  {
184  return hexdec(substr($this->getColor(),4,2));
185  }
+ 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.

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.

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.

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

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

Returns
number

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

References getColor().

Referenced by getDominatAspect(), and getPerceivedBrightness().

174  {
175  return hexdec(substr($this->getColor(),2,2));
176  }
+ 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.

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.

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 194 of file class.ilSystemStyleIconColor.php.

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

Referenced by compareColors().

194  {
195  if($this->brightness === null){
196  $r = $this->getRedAspect();
197  $g = $this->getGreenAspect();
198  $b = $this->getBlueAspect();
199 
200  $this->brightness = sqrt(
201  $r * $r * .299 +
202  $g * $g * .587 +
203  $b * $b * .114);
204  }
205  return $this->brightness;
206  }
getBlueAspect()
Get blue aspect from a color in hex format.
$r
Definition: example_031.php:79
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.

Returns
number

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

References getColor().

Referenced by getDominatAspect(), and getPerceivedBrightness().

165  {
166  return hexdec(substr($this->getColor(),0,2));
167  }
+ 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.

References $color, color, and ilSystemStyleColorException\INVALID_COLOR_EXCEPTION.

Referenced by __construct().

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

◆ setDescription()

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

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

References $description.

Referenced by __construct().

135  {
136  $this->description = $description;
137  }
+ Here is the caller graph for this function:

◆ setId()

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

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

References $id.

Referenced by __construct().

80  {
81  $this->id = $id;
82  }
+ Here is the caller graph for this function:

◆ setName()

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

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

References $name.

Referenced by __construct().

119  {
120  $this->name = $name;
121  }
+ 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: