Horde_Image::brightness PHP Method

brightness() public static method

Returns the brightness of a color.
public static brightness ( string $color ) : integer
$color string An HTML color, e.g.: #ffffcc.
return integer The brightness on a scale of 0 to 255.
    public static function brightness($color)
    {
        list($r, $g, $b) = self::getColor($color);
        return round(($r * 299 + $g * 587 + $b * 114) / 1000);
    }

Usage Example

Esempio n. 1
0
 /**
  * Returns the foreground color.
  *
  * @return string  A HTML color code.
  */
 public function foregroundColor()
 {
     return Horde_Image::brightness($this->backgroundColor()) < 128 ? '#fff' : '#000';
 }
All Usage Examples Of Horde_Image::brightness