File: C:/xampp/htdocs/cieclock/doy.php
<?php
$doys=date('z') + 1;
echo "day of year:".$doys;
//$i=$doys;
$i=$doys;
$sec = 1;
if ($i==''){
$i=$doys;
}
$dgi=$doys*(360/365);
echo "<br>degree of year:".$dgi;
//$i=$i+10;
if ($dgi>=360) {
$dgi=0;
}
//echo "i=".$i;
include 'lab2xyz.php';
function RGBToHex($r, $g, $b) {
//String padding bug found and the solution put forth by Pete Williams (http://snipplr.com/users/PeteW)
$hex = "#";
$hex.= str_pad(dechex($r), 2, "0", STR_PAD_LEFT);
$hex.= str_pad(dechex($g), 2, "0", STR_PAD_LEFT);
$hex.= str_pad(dechex($b), 2, "0", STR_PAD_LEFT);
return $hex;
}
function cieXYZtoSRGB($X, $Y, $Z) {
// Normalize XYZ values
$X /= 1.0;
$Y /= 1.0;
$Z /= 1.0;
// Linear transformation from XYZ to RGB
$R = $X * 3.2406 + $Y * -1.5372 + $Z * -0.4986;
$G = $X * -0.9689 + $Y * 1.8758 + $Z * 0.0415;
$B = $X * 0.0557 + $Y * -0.2040 + $Z * 1.0570;
// Compensate for out-of-range RGB values
$R = ($R > 0.0031308) ? (1.055 * pow($R, (1 / 2.4)) - 0.055) : (12.92 * $R);
$G = ($G > 0.0031308) ? (1.055 * pow($G, (1 / 2.4)) - 0.055) : (12.92 * $G);
$B = ($B > 0.0031308) ? (1.055 * pow($B, (1 / 2.4)) - 0.055) : (12.92 * $B);
// Clamp RGB values to [0, 1] range
$R = max(0, min(1, $R));
$G = max(0, min(1, $G));
$B = max(0, min(1, $B));
// Scale to 8-bit sRGB values
$R = round($R * 255);
$G = round($G * 255);
$B = round($B * 255);
// Return sRGB color array
return [$R, $G, $B];
}
$L=58;
if ($dgi>47){
$L=55;
}
if ($dgi>53){
$L=60;
}
if ($dgi>59){
$L=65;
}
if ($dgi>65){
$L=70;
}
if ($dgi>71){
$L=75;
}
if ($dgi>77){
$L=80;
}
if ($dgi>83){
$L=85;
//$chrome=87;
}
if ($dgi>89){
$L=93;
//$chrome=90;
}
if ($dgi>95){
$L=93;
//$chrome=87;
}
if ($dgi>101){
$L=92;
}
if ($dgi>107){
$L=90;
}
if ($dgi>113){
$L=88;
}
if ($dgi>119){
$L=85;
}
if ($dgi>125){
$L=83;
}
if ($dgi>131){
$L=80;
}
if ($dgi>137){
$L=78;
}
if ($dgi>143){
$L=75;
}
if ($dgi>149){
$L=70;
//$chrome=80;
}
if ($dgi>155){
$L=68;
//$chrome=80;
}
if ($dgi>161){
$L=65;
//$chrome=80;
}
if ($dgi>167){
$L=63;
//$chrome=80;
}
if ($dgi>173){
$L=60;
//$chrome=80;
}
if ($dgi>179){
$L=58;
//$chrome=80;
}
if ($dgi>185){
$L=55;
//$chrome=80;
}
$chrome=80;
$degree=deg2rad($dgi);
$a=cos($degree)*$chrome;
$b=sin($degree)*$chrome;
echo "<br>Lab:".round($L,0).",".round($a,0).",".round($b,0);
//echo "de00:".$de00;
$SXm=lab2xyz("x",$L,$a,$b);
$SYm=lab2xyz("y",$L,$a,$b);
$SZm=lab2xyz("z",$L,$a,$b);
//58.763535563754_74.164133933331_12.406893998571_
// Example usage
$cieXYZ = [$SXm/100, $SYm/100, $SZm/100]; // Example CIE XYZ values
$sRGB = cieXYZtoSRGB($cieXYZ[0], $cieXYZ[1], $cieXYZ[2]);
$sR = $sRGB[0];
$sG = $sRGB[1];
$sB = $sRGB[2];
$secHEX=RGBToHex($sR,$sG,$sB);
$ch1C3=RGBToHex($sR,$sG,$sB);
$dgi=$dgi+1;
?>
<?php
// File path to store hit count
$file_path = 'hit_countdoy.txt';
// Read current hit count from file
$hit_count = (int) file_get_contents($file_path);
// Increment hit count
$hit_count++;
// Write updated hit count to file
file_put_contents($file_path, $hit_count);
// Display hit count
echo "<br>$hit_count";
?>
<html>
<head>
<body style="background-color:<?php echo $ch1C3;?>">
</body>
</html>