ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
Securimage_Color Class Reference
+ Collaboration diagram for Securimage_Color:

Public Member Functions

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

Data Fields

 $r
 $g
 $b

Protected Member Functions

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

Detailed Description

Definition at line 1350 of file securimage.php.

Constructor & Destructor Documentation

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 1367 of file securimage.php.

References constructHTML(), and constructRGB().

{
$args = func_get_args();
if (sizeof($args) == 0) {
$this->r = 255;
$this->g = 255;
$this->b = 255;
} else if (sizeof($args) == 1) {
// set based on html code
if (substr($color, 0, 1) == '#') {
$color = substr($color, 1);
}
if (strlen($color) != 3 && strlen($color) != 6) {
throw new InvalidArgumentException(
'Invalid HTML color code passed to Securimage_Color'
);
}
$this->constructHTML($color);
} else if (sizeof($args) == 3) {
$this->constructRGB($args[0], $args[1], $args[2]);
} else {
throw new InvalidArgumentException(
'Securimage_Color constructor expects 0, 1 or 3 arguments; ' . sizeof($args) . ' given'
);
}
}

+ Here is the call graph for this function:

Member Function Documentation

Securimage_Color::constructHTML (   $color)
protected

Construct from an html hex color code.

Parameters
string$color

Definition at line 1421 of file securimage.php.

Referenced by __construct().

{
if (strlen($color) == 3) {
$red = str_repeat(substr($color, 0, 1), 2);
$green = str_repeat(substr($color, 1, 1), 2);
$blue = str_repeat(substr($color, 2, 1), 2);
} else {
$red = substr($color, 0, 2);
$green = substr($color, 2, 2);
$blue = substr($color, 4, 2);
}
$this->r = hexdec($red);
$this->g = hexdec($green);
$this->b = hexdec($blue);
}

+ Here is the caller graph for this function:

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 1403 of file securimage.php.

Referenced by __construct().

{
if ($red < 0) $red = 0;
if ($red > 255) $red = 255;
if ($green < 0) $green = 0;
if ($green > 255) $green = 255;
if ($blue < 0) $blue = 0;
if ($blue > 255) $blue = 255;
$this->r = $red;
$this->g = $green;
$this->b = $blue;
}

+ Here is the caller graph for this function:

Field Documentation

Securimage_Color::$b

Definition at line 1354 of file securimage.php.

Securimage_Color::$g

Definition at line 1353 of file securimage.php.

Securimage_Color::$r

Definition at line 1352 of file securimage.php.


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