note 74092 added to function.hexdec

From: Date: Sat, 24 Mar 2007 00:23:50 +0000
Subject: note 74092 added to function.hexdec
Groups: php.notes 
Request: Send a blank email to php-notes+get-124767@lists.php.net to get a copy of this message
This tiny function will return foreground colors (either black or white) in contrast to the color you provide: <?php function getContrastColor($color) { return (hexdec($color) > 0xffffff/2) ? '000000' : 'ffffff'; } ?> This function will return the opposite (negative): <?php function negativeColor($color) { //get red, green and blue $r = substr($color, 0, 2); $g = substr($color, 2, 2); $b = substr($color, 4, 2); //revert them, they are decimal now $r = 0xff-hexdec($r); $g = 0xff-hexdec($g); $b = 0xff-hexdec($b); //now convert them to hex and return. return dechex($r).dechex($g).dechex($b); } ?> ---- Server IP: 192.35.244.50 Probable Submitter: 80.120.37.50 ---- Manual Page -- http://www.php.net/manual/en/function.hexdec.php Edit -- https://master.php.net/note/edit/74092 Del: integrated -- https://master.php.net/note/delete/74092/integrated Del: useless -- https://master.php.net/note/delete/74092/useless Del: bad code -- https://master.php.net/note/delete/74092/bad+code Del: spam -- https://master.php.net/note/delete/74092/spam Del: non-english -- https://master.php.net/note/delete/74092/non-english Del: in docs -- https://master.php.net/note/delete/74092/in+docs Del: other reasons-- https://master.php.net/note/delete/74092 Reject -- https://master.php.net/note/reject/74092 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#124767) next »