simple contrast colour in php

I’m just building a website for my small anti-spam verification code, vericode.

There are a few configurable options, background colour being one of them, and to make sure the text is still visible, i used the following PHP to do a simple test against “half of white”, and return either black or white text:

[code]
$bgColour = ‘eaeaea’;
$textColour = (hexdec($bgColour) < 0xffffff/2) ? ‘fff’:’000′;
[/code]




1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *