Permanent link
You’re the inspiration
I consider myself more as a web developer, than as a web designer(or just as a designer). Anyway, I love to design small stuff from time to time - writting some cutting-edge CSS, painting squares, etc. Every designer has an inspiration. And one of my inspirations is the work of one man - Douglas Bowman.
I was "hit" by his recent blog entry, called roulette. And I thought that I can just borrow(but not steal) his idea about random displayed colors every time when a certain page is loaded. Sometimes, the random generators can be very useful and even in this case, when it comes to generate random colors. Sometimes, you will see 2, 3 or more colors in a combination that you never imagine(well, really good designers are maybe seeing the combinations in their minds but not me)
So, my solution is very simple. For the backend, I’m using my favourite PHP and for frontend - XHTML+CSS(I know that the same things can be done with JavaScript but I love PHP).
About the backend - PHP is used in this case to generated 3 random decimal numbers(between 0 and 255), then every number is converted in hexadecimal(and if the hexadecimal is represented with one character, then a leading zero is added just to fit in the HTML color format).
Regarding the frontend - a simple unordered list, every list item is styled to be a square 100px by 100px.
The result - here.
The backend code:
<?php
function make_rand_clr()
{
$raw = dechex(rand(0,255));
if(strlen($raw) == 1)
{
$res = "0". $raw;
}
else
{
$res = $raw;
}
return $res;
}
echo '<ul>'."\n";
for($i = 0; $i < 50; $i++)
{
$clr = make_rand_clr() . make_rand_clr() . make_rand_clr();
echo '<li style="background: #'. $clr .'"><span>#'. $clr .'</span></li>'."\n";
}
echo '</ul>'."\n";
?>
The frontend code - you know how to get it! And once again - thanks, Doug! You’re the inspiration!
24.9.2006 @ 14:14:34 | Category: Css | Comments: Off
