blueshoes php application framework and cms            core_gfx
[ class tree: core_gfx ] [ index: core_gfx ] [ all elements ]

Class: Bs_ColorCodes

Source Location: /core/gfx/Bs_ColorCodes.class.php

Class Overview

Bs_Object
   |
   --Bs_ColorCodes

ColorCodes class.


Author(s):

Version:

  • 4.3.$Revision: 1.3 $ $Date: 2003/10/29 17:48:37 $

Copyright:

  • blueshoes.org

Variables

Methods


Inherited Variables

Inherited Methods

Class: Bs_Object

Bs_Object::Bs_Object()
Bs_Object::getErrors()
Basic error handling: Get *all* errors as string array from the global Bs_Error-error stack.
Bs_Object::getLastError()
Basic error handling: Get last error string from the global Bs_Error-error stack.
Bs_Object::getLastErrors()
Basic error handling: Get last errors string array from the global Bs_Error-error stack sinc last call of getLastErrors().
Bs_Object::persist()
Persists this object by serializing it and saving it to a file with unique name.
Bs_Object::setError()
Basic error handling: Push an error string on the global Bs_Error-error stack.
Bs_Object::toHtml()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::toString()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::unpersist()
Fetches an object that was persisted with persist()

Class Details

[line 69]
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 the combination of Red, Green, and Blue color values (RGB). The lowest 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 both Netscape and Internet Explorer (and others).

Note: Color names are not supported by the W3C standards. If you want to write correct CSS you should use the Color HEX values.

(as i read on http://www.w3.org/TR/REC-html40/types.html in the section "6.5 Colors", the w3c supports 16 color names.)

Web Safe Colors A 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 reason for 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 to 16384 (or even 256).

dependencies: none




Tags:

access:  public
pattern:  singleton: (pseudostatic)
since:  bs4.2
version:  4.3.$Revision: 1.3 $ $Date: 2003/10/29 17:48:37 $
copyright:  blueshoes.org
author:  andrej arn <at blueshoes dot org>


[ Top ]


Class Variables

$_namedColors =

[line 84]

static array of named colors.



Tags:

var:  (hash)
see:  _createNamedColors()

Type:   array


[ Top ]

$_webSafe =

[line 76]


Type:   array


[ Top ]



Class Methods


constructor Bs_ColorCodes [line 98]

Bs_ColorCodes Bs_ColorCodes( )

constructor



[ Top ]

method createDifferentColors [line 325]

array createDifferentColors( int $num, [bool $noWhite = TRUE], [bool $returnRgb = FALSE], [bool $usePredefined = TRUE])

creates the given number of different colors.



Tags:

return:  (vector filled with 6-char hex values)
since:  bs4.3
access:  public


Parameters:

int   $num   (the number of colors you want.)
bool   $noWhite   (default is TRUE. clean white won't be used (ffffff aka 255/255/255).)
bool   $returnRgb   (by default we return hex values. if you want an rgb array returned (vector in vector) set this to true.)
bool   $usePredefined   (use the available predefined, hand-picked colors. this is recommended, they look good and different.)

[ Top ]

method dumpWebSafe [line 285]

string dumpWebSafe( )

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



Tags:

access:  public


[ Top ]

method getWebSafe [line 182]

array getWebSafe( )

returns an array with the 216 websafe colors.



Tags:

return:  (vector)
access:  public


[ Top ]

method hexToRgb [line 109]

void hexToRgb( string $hex)

converts a hex value to an rgb value.



Tags:

access:  public


Parameters:

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

[ Top ]

method isDark [line 170]

bool isDark( string $colorCode)

tells if a color is dark or light.

this can be used to define a foreground color on a given background color. on dark bg's you need light foreground colors etc. some colors are somewhere in between. then it doesn't really matter.

the logic: (well check the source)




Tags:

return:  (TRUE=dark, FALSE=bright)
access:  public


Parameters:

string   $colorCode   (hex, like 'FFFFFF')

[ Top ]

method isGray [line 243]

bool isGray( string $colorCode)

tells if the color specified is gray, that means somewhere between (including) 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 A9A9A9 black is 000000 white is FFFFFF




Tags:

access:  public


Parameters:

string   $colorCode   (hex, like 'FFFFFF')

[ Top ]

method isWebSafe [line 308]

bool isWebSafe( string $colorCode)

tells if the given color is websafe or not.



Parameters:

string   $colorCode   (hex, like 'FFFFFF')

[ Top ]

method makeWebSafe [line 195]

string makeWebSafe( string $colorCode)



Tags:

return:  (hex code)
access:  public


Parameters:

string   $colorCode   (hex, like 'FFFFFF')

[ Top ]

method nameToHex [line 147]

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: 00FFFF 2) "Fuchsia" and "Magenta" produce the same color: FF00FF 3) "Gray" and "Grey" are both correct english (is one uk and one us?) but browsers only know the "Gray" version. so here it's the same.




Tags:

return:  (eg FFFFFF)
throws:  bool FALSE (if the name is unknown)
access:  public


Parameters:

string   $colorName  

[ Top ]

method rgbToHex [line 121]

string rgbToHex( array $rgb)

converts an rgb value to a hex value.



Tags:

return:  (eg FFFFFF)
access:  public


Parameters:

array   $rgb   (vector with 3 elements)

[ Top ]

method toGray [line 260]

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.




Tags:

return:  (hex color code)
access:  public


Parameters:

string   $colorCode   (hex, like 'FFFFFF')

[ Top ]

method _cleanCode [line 391]

string _cleanCode( string $colorCode)

cleans a color code.

the user may send us something like #ffffff, but what we want is FFFFFF, so uppercase and 6 chars.




Tags:

return:  (hex color code)


Parameters:

string   $colorCode  

[ Top ]


Documentation generated on Mon, 29 Dec 2003 21:08:17 +0100 by phpDocumentor 1.2.3