}
class WebColor {
-
// XXX: Maybe make getters and setters for r,g,b values and tuples,
// e.g.: to support this kinda CSS representation: rgb(255,0,0)
// http://www.w3.org/TR/CSS21/syndata.html#color-units
*
* @return nothing
*/
-
function parseColor($color) {
if (is_numeric($color)) {
*
* @return nothing
*/
-
function setNamedColor($name)
{
// XXX Implement this
}
-
/**
* Sets the RGB color values from a a hex tuple
*
*
* @return nothing
*/
-
function setHexColor($hexcolor) {
if ($hexcolor[0] == '#') {
$hexcolor[1].$hexcolor[1],
$hexcolor[2].$hexcolor[2]);
} else {
- $errmsg = _('%s is not a valid color! Use 3 or 6 hex chars.');
+ // TRANS: Validation error for a web colour.
+ // TRANS: %s is the provided (invalid) text for colour.
+ $errmsg = _('%s is not a valid color! Use 3 or 6 hex characters.');
throw new WebColorException(sprintf($errmsg, $hexcolor));
}
*
* @return nothing
*/
-
function setIntColor($intcolor)
{
// We could do 32 bit and have an alpha channel because
*
* @return string
*/
-
function hexValue() {
$hexcolor = (strlen(dechex($this->red)) < 2 ? '0' : '' ) .
dechex($this->blue);
return strtoupper($hexcolor);
-
}
/**
*
* @return int
*/
-
function intValue()
{
$intcolor = 256 * 256 * $this->red + 256 * $this->green + $this->blue;
class WebColorException extends Exception
{
}
-
-?>
\ No newline at end of file