Skip to content

PHP: Spaß mit Farben

von dennis

Hier mal ein paar Codeschnipsel rund um das Thema Farben:

Luminanz (Helligkeitswert) eines Farbtons:

$red = 255;
$green = 170;
$blue = 0;
// 0=dunkel, 255 = hell :
$l = round((0.2126 * $blue) + (0.7152 * $green) + (0.0722 * $blue));

Komplementärfarbe eines Farbtons:

$color = 'FFAA00';
$ccolor  = sprintf('%06X',(~(1*('0x'.$color))&0xFFFFFF));

Aus → PHP

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS

*