public static function brightness($color) { list($r, $g, $b) = self::getColor($color); return round(($r * 299 + $g * 587 + $b * 114) / 1000); }
/** * Returns the foreground color. * * @return string A HTML color code. */ public function foregroundColor() { return Horde_Image::brightness($this->backgroundColor()) < 128 ? '#fff' : '#000'; }