Umfragen
chart_color Class Reference

holds colors and generates them if there are none left More...

Public Member Functions

 __construct ()
 rewind ()
 current ()
 key ()
 next ()
 valid ()
 offsetSet ($offset, $value)
 offsetGet ($offset)
 offsetExists ($offset)
 offsetUnset ($offset)
 hsv2rgb ($h, $s, $v)
 converts a hsv color value to rgb [0,1]
 rgbbase255 (array $rgb)
 converts rgb values from 0-1 to 0-255 and rounds it
 rgb2html ($r, $g, $b)
 converts RGB values between 0 and 255 to HTML notation
 rgba2html ($r, $g, $b, $a)
 makes rgba() html notation
 random_hue ()
 make a random hue bentween 0 and 360 based on phi and rand
 random_color ($hue=null)
 generates a random color based on preset saturation and value values
 many_unique_random_colors ($num, $thresold=10, $thresold2=30)
 makes a list of unique colors
 test_many_colors ()
 displays a table of test colors produced by many_unique_random_colors()
 getRGBA ($offset, $a)

Private Member Functions

 make_extracolors ()

Private Attributes

 $position
 $colors = array()
 $extraColors = null

Detailed Description

holds colors and generates them if there are none left

Definition at line 36 of file chart.class.php.

Constructor & Destructor Documentation

__construct ( )

Definition at line 52 of file chart.class.php.

Member Function Documentation

current ( )

Definition at line 60 of file chart.class.php.

getRGBA (   $offset,
  $a 
)

Definition at line 343 of file chart.class.php.

hsv2rgb (   $h,
  $s,
  $v 
)

converts a hsv color value to rgb [0,1]

Parameters
$hHue value between 0 and 360°
$sSatuation percent value between 0 and 1
$vValue percent value between 0 and 1
Returns
array with R, G and B values between 0 and 1
Exceptions
exceptionwhen the HSV values are not correct

Definition at line 131 of file chart.class.php.

key ( )

Definition at line 64 of file chart.class.php.

make_extracolors ( )
private

Definition at line 41 of file chart.class.php.

many_unique_random_colors (   $num,
  $thresold = 10,
  $thresold2 = 30 
)

makes a list of unique colors

Parameters
int$numhow many colors should we try to generate
int$thresoldacceptable margin where a generated Hue value (between 0 and 360) can be set as unique. The lower, the more colors can be retrieved but the more the colors will be similar
int$thresold2acceptable margin where a generated Hue value (between 0 and 360) can be alike his predecessor
Returns
array of hsv color arrays, depending on the restrictions set not even at all the requested size

Definition at line 255 of file chart.class.php.

next ( )

Definition at line 68 of file chart.class.php.

offsetExists (   $offset)

Definition at line 103 of file chart.class.php.

offsetGet (   $offset)

Definition at line 86 of file chart.class.php.

offsetSet (   $offset,
  $value 
)

Definition at line 78 of file chart.class.php.

offsetUnset (   $offset)

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

random_color (   $hue = null)

generates a random color based on preset saturation and value values

Parameters
int$hueoptional if not given a random hue will be produced
Returns
array of rgb values between 0 and 1

Definition at line 234 of file chart.class.php.

random_hue ( )

make a random hue bentween 0 and 360 based on phi and rand

Returns
int somewhere bentween 0 and 360

Definition at line 221 of file chart.class.php.

rewind ( )

Definition at line 56 of file chart.class.php.

rgb2html (   $r,
  $g,
  $b 
)

converts RGB values between 0 and 255 to HTML notation

Parameters
$rRed value between 0 and 255
$gGreen value between 0 and 255
$bBlue value between 0 and 255
Returns
string html notation with leading #

Definition at line 196 of file chart.class.php.

rgba2html (   $r,
  $g,
  $b,
  $a 
)

makes rgba() html notation

Parameters
$rRed value between 0 and 255
$gGreen value between 0 and 255
$bBlue value between 0 and 255
$aTransparency value between 0 and 1
Returns
string html notation with leading #

Definition at line 212 of file chart.class.php.

rgbbase255 ( array  $rgb)

converts rgb values from 0-1 to 0-255 and rounds it

Parameters
array$rgban array with values for RGB all between 0 and 1
Returns
array with RGB values between 0 and 255 rounded
Exceptions
exceptionwhen the array has not exactly 3 values or one of the values is not between 0 and 1

Definition at line 173 of file chart.class.php.

test_many_colors ( )

displays a table of test colors produced by many_unique_random_colors()

Definition at line 322 of file chart.class.php.

valid ( )

Definition at line 72 of file chart.class.php.

Field Documentation

$colors = array()
private

Definition at line 38 of file chart.class.php.

$extraColors = null
private

Definition at line 39 of file chart.class.php.

$position
private

Definition at line 37 of file chart.class.php.


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