ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Securimage_Color Class Reference
+ Collaboration diagram for Securimage_Color:

Public Member Functions

 __construct ($color='#ffffff')
 Create a new Securimage_Color object. More...
 

Data Fields

 $r
 
 $g
 
 $b
 

Protected Member Functions

 constructRGB ($red, $green, $blue)
 Construct from an rgb triplet. More...
 
 constructHTML ($color)
 Construct from an html hex color code. More...
 

Detailed Description

Definition at line 2125 of file securimage.php.

Constructor & Destructor Documentation

◆ __construct()

Securimage_Color::__construct (   $color = '#ffffff')

Create a new Securimage_Color object.


Constructor expects 1 or 3 arguments.
When passing a single argument, specify the color using HTML hex format,
when passing 3 arguments, specify each RGB component (from 0-255) individually.
$color = new Securimage_Color('#0080FF') or
$color = new Securimage_Color(0, 128, 255)

Parameters
string$color
Exceptions
Exception

Definition at line 2142 of file securimage.php.

2143  {
2144  $args = func_get_args();
2145 
2146  if (sizeof($args) == 0) {
2147  $this->r = 255;
2148  $this->g = 255;
2149  $this->b = 255;
2150  } else if (sizeof($args) == 1) {
2151  // set based on html code
2152  if (substr($color, 0, 1) == '#') {
2153  $color = substr($color, 1);
2154  }
2155 
2156  if (strlen($color) != 3 && strlen($color) != 6) {
2157  throw new InvalidArgumentException(
2158  'Invalid HTML color code passed to Securimage_Color'
2159  );
2160  }
2161 
2162  $this->constructHTML($color);
2163  } else if (sizeof($args) == 3) {
2164  $this->constructRGB($args[0], $args[1], $args[2]);
2165  } else {
2166  throw new InvalidArgumentException(
2167  'Securimage_Color constructor expects 0, 1 or 3 arguments; ' . sizeof($args) . ' given'
2168  );
2169  }
2170  }
constructHTML($color)
Construct from an html hex color code.
constructRGB($red, $green, $blue)
Construct from an rgb triplet.

Member Function Documentation

◆ constructHTML()

Securimage_Color::constructHTML (   $color)
protected

Construct from an html hex color code.

Parameters
string$color

Definition at line 2196 of file securimage.php.

References $blue, $green, and $red.

2197  {
2198  if (strlen($color) == 3) {
2199  $red = str_repeat(substr($color, 0, 1), 2);
2200  $green = str_repeat(substr($color, 1, 1), 2);
2201  $blue = str_repeat(substr($color, 2, 1), 2);
2202  } else {
2203  $red = substr($color, 0, 2);
2204  $green = substr($color, 2, 2);
2205  $blue = substr($color, 4, 2);
2206  }
2207 
2208  $this->r = hexdec($red);
2209  $this->g = hexdec($green);
2210  $this->b = hexdec($blue);
2211  }
$blue
Definition: example_030.php:81
$red
Definition: example_030.php:80
$green
Definition: example_030.php:83

◆ constructRGB()

Securimage_Color::constructRGB (   $red,
  $green,
  $blue 
)
protected

Construct from an rgb triplet.

Parameters
int$redThe red component, 0-255
int$greenThe green component, 0-255
int$blueThe blue component, 0-255

Definition at line 2178 of file securimage.php.

References $blue, $green, and $red.

2179  {
2180  if ($red < 0) $red = 0;
2181  if ($red > 255) $red = 255;
2182  if ($green < 0) $green = 0;
2183  if ($green > 255) $green = 255;
2184  if ($blue < 0) $blue = 0;
2185  if ($blue > 255) $blue = 255;
2186 
2187  $this->r = $red;
2188  $this->g = $green;
2189  $this->b = $blue;
2190  }
$blue
Definition: example_030.php:81
$red
Definition: example_030.php:80
$green
Definition: example_030.php:83

Field Documentation

◆ $b

Securimage_Color::$b

Definition at line 2129 of file securimage.php.

◆ $g

Securimage_Color::$g

Definition at line 2128 of file securimage.php.

◆ $r

Securimage_Color::$r

Definition at line 2127 of file securimage.php.


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