note 63600 deleted from function.abs by bjori
| From: | bjori@php.net | Date: | Sat, 25 Mar 2006 10:49:14 +0000 |
| Subject: | note 63600 deleted from function.abs by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-106567@lists.php.net to get a copy of this message | ||
Note Submitter: tech at manorrealty dot net
Reason: useless
----
Here's a cool little script I made for taking the time of day and converting it to a brightness
of teal. Closer to noon it is the brighter it is. Uses abs create the ^ like formula where the peak
is noon. Outputs a 6 digit rgb color.
<?
$hour = date('G');
$timeinput = abs(abs(($hour - 12) * 2) - 24) ;
$value = explode(".",($timeinput * 255) / 24);
$_number = $value[0];
$_base = "16";
//CONVERT TO BASE
function converttobase($inputnumber,$base) {
while ($answers[0] != "0") {
if ($answers[0]) {
$number = $answers[0]; } else {
$number = $inputnumber; }
$answer = $number / $base;
$answers = explode(".",$answer);
$remainder = $number - ($answers[0] * $base);
if ($remainder == "") { $remainder = '0'; }
if ($remainder == "10") { $remainder = 'A'; }
if ($remainder == "11") { $remainder = 'B'; }
if ($remainder == "12") { $remainder = 'C'; }
if ($remainder == "13") { $remainder = 'D'; }
if ($remainder == "14") { $remainder = 'E'; }
if ($remainder == "15") { $remainder = 'F'; }
$finalanswer .= $remainder;
}
if (strlen($finalanswer) < '2') { $finalanswer .= '0'; }
return strrev($finalanswer);
}
//CONVERT TO BASE END
$output = converttobase($_number,$_base);
$fraction = explode(".",($_number * $_number)/255);
$output2 = converttobase($fraction[0],16);
echo ($output2); echo ($output); echo ($output);
?>