File: C:/xampp/htdocs/cieclock/doyColor.php
<?php
$pmon=$_POST['pmon'];
$pdate=$_POST['pdate'];
//echo "mon:".$pmon.",date:".$pdate;
$dateC = new DateTime('2025-'.$pmon.'-'.$pdate);
// Get the day of the year
$dayOfYear = $dateC->format('z') + 1; // Adding 1 because 'z' is zero-based
echo "The day number of your birthday: " . $dayOfYear;
$doys= $dayOfYear;
//echo "day of year:".$doys;
//$i=$doys;
$i=$doys;
$sec = 1;
if ($i==''){
$i=$doys;
}
$dgi=$doys*(360/365);
//echo "<br>degree:".round($dgi,2);
//$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 "<br>chrome:".round($chrome,0)."<br>degree:".round($dgi,2);
//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);
echo "<br>RGB:".$sRGB[0].",".$sRGB[1].",".$sRGB[2];
////////////////////////////////////////////////////////////////////
$myFile ="rgbOne.txt";
$fvcc = fopen($myFile, 'w') or die("can't open file");
$viHeadM='CGATS.17
ORIGINATOR "icctrans"
#
# Data follows
#
NUMBER_OF_SETS 1
NUMBER_OF_FIELDS 4
BEGIN_DATA_FORMAT
SAMPLE_ID RGB_R RGB_G RGB_B
END_DATA_FORMAT
BEGIN_DATA';
fwrite($fvcc, $viHeadM."\n");
$labdata='1 '.$sRGB[0].' '.$sRGB[1].' '.$sRGB[2];
fwrite($fvcc, $labdata."\n");
$enddata='END_DATA';
fwrite($fvcc, $enddata."\n");
fclose($fvcc);
$command = escapeshellcmd('icctrans.exe -isRGB.icm -oCRPC6.icm -t2 rgbOne.txt out.txt');
$output = shell_exec($command);
sleep(1);
$contentTx = file("out.txt");
$stringTx = implode($contentTx);
$dotTx = explode(" ", $stringTx);////Measure upload
//print_r ($dotTx);
$Tc=round($dotTx[8],0);$Tm=round($dotTx[9],0);$Ty=round($dotTx[10],0);
//echo "<br>CMY:".$Tc.",".$Tm.",".$Ty;
$command2 = escapeshellcmd('icctrans.exe -iCRPC6.icm -o*Lab -t3 out.txt Lab.txt');
$output2 = shell_exec($command2);
sleep(1);
$contentTx = file("Lab.txt");
$stringTx = implode($contentTx);
$dotT = explode(" ", $stringTx);////Measure upload
//print_r ($dotT);
$TL=round($dotT[7],0);$Ta=round($dotT[8],0);$Tb=round($dotT[9],0);
$chrome=pow(pow($Ta,2)+pow($Tb,2),0.5);
$degreeC=deg2rad($dgi);
$at=round(cos($degreeC)*$chrome,0);
$bt=round(sin($degreeC)*$chrome,0);
$myFile ="Labx.txt";
$fvcc = fopen($myFile, 'w') or die("can't open file");
$viHeadM='CGATS.17
ORIGINATOR "icctrans"
#
# Data follows
#
NUMBER_OF_SETS 1
NUMBER_OF_FIELDS 4
BEGIN_DATA_FORMAT
SAMPLE_ID LAB_L LAB_A LAB_B
END_DATA_FORMAT
BEGIN_DATA';
fwrite($fvcc, $viHeadM."\n");
$labdata='1 '.$TL.' '.$at.' '.$bt;
fwrite($fvcc, $labdata."\n");
$enddata='END_DATA';
fwrite($fvcc, $enddata."\n");
fclose($fvcc);
//echo "<br>Lab:".$TL.",".$Ta.",".$Tb;
$command3 = escapeshellcmd('icctrans.exe -i*Lab -osRGB.icm -t2 Labx.txt sRGB.txt');
$output3 = shell_exec($command3);
sleep(1);
$contentTx = file("sRGB.txt");
$stringTx = implode($contentTx);
$dotTs = explode(" ", $stringTx);////Measure upload
//print_r ($dotTs);
$TR=round($dotTs[7],0);$TG=round($dotTs[8],0);$TBs=round($dotTs[9],0);
//echo "<br>RGB:".$TR.",".$TG.",".$TBs;
$chrome=pow(pow($at,2)+pow($bt,2),0.5);
$angle_radians = atan2($at, $bt);
// Convert the angle from radians to degrees
$angle_degrees = round(rad2deg($angle_radians),1);
// Ensure the angle is positive (0 to 360 degrees)
if ($angle_degrees < 0) {
$angle_degrees += 360;
}
//echo "The degree of the point ($x, $y) is: $angle_degrees degrees";
//echo "<br>chrome:".round($chrome,0)."<br>degree:".round($angle_degrees,2);
$ch1C3=RGBToHex($sR,$sG,$sB);
$ch1C4=RGBToHex($TR,$TG,$TBs);
//$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>count:$hit_count";
?>
<html>
<head>
<body style="background-color:<?php echo $ch1C3;?>">
<table width="400" border="0" align="center" bgcolor="<?php echo $ch1C4;?>" >
<tr>
<td>here is your CMY info:</td></tr>
<tr>
<td><?php echo "CMY:".$Tc.",".$Tm.",".$Ty;?></td>
</tr>
<tr>
<td><?php echo "Lab:".$TL.",".$at.",".$bt;?></td>
</tr>
<tr>
<td><?php echo "degree: ".round($dgi,2);?></td>
</tr>
<tr>
<td><?php echo "chrome:".round($chrome,0);?></td>
</tr>
<tr>
<td><?php echo "Display RGB:".$TR.",".$TG.",".$TBs;?></td>
</tr>
</table>
</body>
</html>