ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 2197 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 2214 of file securimage.php.

2215  {
2216  $args = func_get_args();
2217 
2218  if (sizeof($args) == 0) {
2219  $this->r = 255;
2220  $this->g = 255;
2221  $this->b = 255;
2222  } elseif (sizeof($args) == 1) {
2223  // set based on html code
2224  if (substr($color, 0, 1) == '#') {
2225  $color = substr($color, 1);
2226  }
2227 
2228  if (strlen($color) != 3 && strlen($color) != 6) {
2229  throw new InvalidArgumentException(
2230  'Invalid HTML color code passed to Securimage_Color'
2231  );
2232  }
2233 
2234  $this->constructHTML($color);
2235  } elseif (sizeof($args) == 3) {
2236  $this->constructRGB($args[0], $args[1], $args[2]);
2237  } else {
2238  throw new InvalidArgumentException(
2239  'Securimage_Color constructor expects 0, 1 or 3 arguments; ' . sizeof($args) . ' given'
2240  );
2241  }
2242  }
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 2280 of file securimage.php.

References $blue, $green, and $red.

2281  {
2282  if (strlen($color) == 3) {
2283  $red = str_repeat(substr($color, 0, 1), 2);
2284  $green = str_repeat(substr($color, 1, 1), 2);
2285  $blue = str_repeat(substr($color, 2, 1), 2);
2286  } else {
2287  $red = substr($color, 0, 2);
2288  $green = substr($color, 2, 2);
2289  $blue = substr($color, 4, 2);
2290  }
2291 
2292  $this->r = hexdec($red);
2293  $this->g = hexdec($green);
2294  $this->b = hexdec($blue);
2295  }
$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 2250 of file securimage.php.

References $blue, $green, and $red.

2251  {
2252  if ($red < 0) {
2253  $red = 0;
2254  }
2255  if ($red > 255) {
2256  $red = 255;
2257  }
2258  if ($green < 0) {
2259  $green = 0;
2260  }
2261  if ($green > 255) {
2262  $green = 255;
2263  }
2264  if ($blue < 0) {
2265  $blue = 0;
2266  }
2267  if ($blue > 255) {
2268  $blue = 255;
2269  }
2270 
2271  $this->r = $red;
2272  $this->g = $green;
2273  $this->b = $blue;
2274  }
$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 2201 of file securimage.php.

◆ $g

Securimage_Color::$g

Definition at line 2200 of file securimage.php.

◆ $r

Securimage_Color::$r

Definition at line 2199 of file securimage.php.


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