Class HSVClass

Description

The HSV Class and the accompanying functions allow you to convert between HSV and RGB.

RGB is what the computer understands. HSV is what people can use to easily work with colors. This code gives you the tools to convert between the two models.

PHP Version 4

LICENSE: This class is subject to the freebsd license found at http://freebsd.org/copyright/license.html.

Located in /HSVClass.php (line 42)


	
			
Variable Summary
float $m_hue
Method Summary
HSVClass HSVClass (mixed $arg_hue, mixed $arg_saturation, mixed $arg_brightness)
void changeBrightness (float $arg_amount)
void changeHue (float $arg_degrees)
void changeSaturation (float $arg_amount)
array getHSV ()
array getRGB ()
string getRGBString ()
bool setHSV (float $arg_h, float $arg_s, float $arg_v)
bool setRGB (integer $arg_r, integer $arg_g, integer $arg_b)
bool setRGBString (string $arg_html_string)
Variables
float $m_brightness (line 72)

$m_brightness

The current brightness. Valid values range from 0 to 1.

  • access: public
float $m_hue (line 52)

$m_hue

The current hue. Valid values range from 0 to 360

  • access: public
float $m_saturation (line 62)

$m_saturation

The current saturation. Valid values range from 0 to 1.

  • access: public
Methods
Constructor HSVClass (line 80)

Constructor - initializes the variables

HSVClass HSVClass (mixed $arg_hue, mixed $arg_saturation, mixed $arg_brightness)
changeBrightness (line 166)

Alters the brightness of the current color

The value passed in should be greater than negative one and less than one. If by changing brightness it becomes greater than one or less than zero, the brightness wraps around. For instance, adding +.2 to a value of .9 leaves you with .1

  • access: public
void changeBrightness (float $arg_amount)
  • float $arg_amount: is the total amount of brightness to be added to the current color, between -1 and 1
changeHue (line 205)

Alters the hue of the current color

  • access: public
void changeHue (float $arg_degrees)
  • float $arg_degrees: is the amount of change from the current hue
changeSaturation (line 188)

Alters the saturation of the current color

The value passed in should be greater than -1 and less than 1. If by changing the saturation the value becomes greater than 1 or less than 0, the brightness wraps around. For instance, adding +.2 to a value of .9 leaves you with .1.

  • access: public
void changeSaturation (float $arg_amount)
  • float $arg_amount: is the total amount of saturation to be added to the current color, between -1 and 1
getHSV (line 260)

Returns an array containing the hue, saturation and brightness

  • access: public
array getHSV ()
getRGB (line 221)

Returns array of the current color

  • return: using template array ("r"=>?, "g"=>?, b=>?);
  • access: public
array getRGB ()
getRGBString (line 238)

Return HTML string of current color

  • return: current color in FFFFFF format
  • access: public
string getRGBString ()
setHSV (line 97)

sets the current color

Sets the HSV values, overwriting whatever was there previously.

  • return: True if successful, false otherwise
  • access: public
bool setHSV (float $arg_h, float $arg_s, float $arg_v)
  • float $arg_h: The hue must be between 0 and 360
  • float $arg_s: The saturation must be between 0 and 1
  • float $arg_v: the brightness must be between 0 and 1
setRGB (line 122)

sets the current color

The RGB is immediately converted in HSV and stored

  • return: true if successful, false otherwie
  • access: public
bool setRGB (integer $arg_r, integer $arg_g, integer $arg_b)
  • integer $arg_r: The red color must between 0 and 255
  • integer $arg_g: The green color must between 0 and 255
  • integer $arg_b: The blue color must between 0 and 255
setRGBString (line 141)

sets the current color

Sets the HSV values, overwriting whatever was there previously. The string is in #FFFFFF format.

  • return: True if successful, false is not
  • access: public
bool setRGBString (string $arg_html_string)
  • string $arg_html_string: color in RGB string format (i.e. FFFFFF)

Documentation generated on Tue, 06 Sep 2005 00:57:20 -0400 by phpDocumentor 1.3.0RC3