BlueShoes Application Framework made with PHP http://www.blueshoes.org/


Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: C:/usr/local/lib/php/blueshoes-4.2/core/gfx/Bs_ColorCodes.class.php
BlueShoes Application Framework - gfx

Bs_ColorCodes

Bs_Object
   |
  +-- Bs_ColorCodes

ColorCodes class.

 

public class Bs_ColorCodes extends Bs_Object

ColorCodes class.
much of the following text comes from:http://www.w3schools.com/html/html_colors.asp[CSS] colors are defined using a hexadecimal notation for thecombination of Red, Green, and Blue color values (RGB). Thelowest value that can be given to one light source is 0 (hex #00).The highest value is 255 (hex #FF).A collection of color names are supported by newer versions of bothNetscape and Internet Explorer (and others).Note: Color names are not supported by the W3C standards. If you wantto write correct CSS you should use the Color HEX values.(as i read on http://www.w3.org/TR/REC-html40/types.html in thesection "6.5 Colors", the w3c supports 16 color names.)Web Safe ColorsA few years ago, when most computers supported only 256 different colors,a list of 216 Web Safe Colors was suggested as a Web standard. The reasonfor this was that Microsoft and Mac operating system used 40 different"reserved" fixed system colors (about 20 each).the case of hex numbers does not matter. FFFFFF and ffffff are both correct.by using hex color codes, you can produce more than 16 mio different colors.nowadays most monitors can handle that, altough some are still limited to16384 (or even 256).Black = "#000000" Green = "#008000"Silver = "#C0C0C0" Lime = "#00FF00"Gray = "#808080" Olive = "#808000"White = "#FFFFFF" Yellow = "#FFFF00"Maroon = "#800000" Navy = "#000080"Red = "#FF0000" Blue = "#0000FF"Purple = "#800080" Teal = "#008080"Fuchsia = "#FF00FF" Aqua = "#00FFFF"aqua black blue fuchsia green graylime maroon navy olive purple redsilver teal white yellow(defined in html 3.2)http://www.htmlgoodies.com/tutors/colors.htmldependencies: none

Authors
Sincebs4.2
Version4.0.$id$
Copyrightblueshoes.org

 

Methods inherited from Bs_Object

isex, isexception, tostring, tohtml, persist, unpersist, bs_object, bbsetoutput, bbawake, bbisawake, bbxmsg, bbxfunctionstart, bbxfunctionend, bbxecho, bbxvar, bbxvardump, bbforcetrace, bbbufferstart, bbbufferget, bbbufferendflush, bbbufferendclean

Public Method Summary

void

Bs_ColorCodes()

constructor
void

hexToRgb(string $hex)

converts a hex value to an rgb value.
string

rgbToHex(array $rgb)

converts an rgb value to a hex value.
string

nameToHex(string $colorName)

converts a color name to its hex color code.
bool

isDark(string $colorCode)

tells if a color is dark or light.
array

getWebSafe()

returns an array with the 216 websafe colors.
string

makeWebSafe(string $colorCode)

bool

isGray(string $colorCode)

tells if the color specified is gray, that means somewhere between
string

toGray(string $colorCode)

converts a color to a gray scale color.
string

dumpWebSafe()

returns rendered html code that displays an html table

Private Method Summary

bool

isWebSafe(string $colorCode)

tells if the given color is websafe or not.
string

_cleanCode(string $colorCode)

cleans a color code.
void

_createWebSafe()

inits the static var $this->_webSafe if it has not
void

_createNamedColors()

inits the static var $this->_namedColors if it has not

Private Field Summary

array

$_webSafe

array

$_namedColors

unknown

$this

Private Constant Summary

BS_COLORCODES_VERSION >>4.0.$x$<< Warning: documentation is missing.

Public Method Details

Bs_ColorCodes

public void Bs_ColorCodes( )

  constructor

Returns void


hexToRgb

public void hexToRgb( string $hex )

  converts a hex value to an rgb value.

Parameter
string $hex
(eg FFFFFF)
return array (vector with 3 elements)
Returns void


rgbToHex

public string rgbToHex( array $rgb )

  converts an rgb value to a hex value.

Parameter
array $rgb
(vector with 3 elements)
Returns string

(eg FFFFFF)


nameToHex

public string nameToHex( string $colorName )

  converts a color name to its hex color code.
the color name from ie/ns are known (check the kb).note: 1) "Aqua" and "Cyan" produce the same color: 00FFFF2) "Fuchsia" and "Magenta" produce the same color: FF00FF3) "Gray" and "Grey" are both correct english (is one ukand one us?) but browsers only know the "Gray" version.so here it's the same.

Parameter
string $colorName
Returns string

(eg FFFFFF)

Throws bool FALSE (if the name is unknown)

isDark

public bool isDark( string $colorCode )

  tells if a color is dark or light.
this can be used to define a foreground color on a givenbackground color. on dark bg's you need light foregroundcolors etc.some colors are somewhere in between. then it doesn'treally matter.the logic: (well check the source)

Parameter
string $colorCode
(hex, like 'FFFFFF')
Returns bool

(TRUE=dark, FALSE=light)


getWebSafe

public array getWebSafe( )

  returns an array with the 216 websafe colors.

Returns array

(vector)


makeWebSafe

public string makeWebSafe( string $colorCode )

 

Parameter
string $colorCode
(hex, like 'FFFFFF')
Returns string

(hex code)


isGray

public bool isGray( string $colorCode )

  tells if the color specified is gray, that means somewhere between
(uncluding) black and white.a color is gray if the red, green and blue values all are the same(you take the same amount of each color).examples: darkgray is A9A9A9black is 000000white is FFFFFF

Parameter
string $colorCode
(hex, like 'FFFFFF')
Returns bool


toGray

public string toGray( string $colorCode )

  converts a color to a gray scale color.
works, but could do better. the light thing is not perfect. check the source.

Parameter
string $colorCode
(hex, like 'FFFFFF')
Returns string

(hex color code)


dumpWebSafe

public string dumpWebSafe( )

  returns rendered html code that displays an html table
with all the 216 websafe colors in it.

Returns string


Private Method Details

isWebSafe

private bool isWebSafe( string $colorCode )

  tells if the given color is websafe or not.

Parameter
string $colorCode
(hex, like 'FFFFFF')
Returns bool


_cleanCode

private string _cleanCode( string $colorCode )

  cleans a color code.
the user may send us something like #ffffff, butwhat we want is FFFFFF, so uppercase and 6 chars.

Parameter
string $colorCode
Returns string

(hex color code)


_createWebSafe

private void _createWebSafe( )

  inits the static var $this->_webSafe if it has not
already been done before.

Returns void


_createNamedColors

private void _createNamedColors( )

  inits the static var $this->_namedColors if it has not
already been done before.

Returns void


Private Field Details

$_webSafe

private array $_webSafe

>><<



$_namedColors

private array $_namedColors

>><<



$this

private unknown $this

>><<



Private Constant Details

BS_COLORCODES_VERSION

define( BS_COLORCODES_VERSION, >>4.0.$x$<< )
Case: default: case sensitive




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta