HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/xampp/htdocs/cieclock/refresh_table2.php
<?php
// Your PHP script to generate the table content goes here
// For demonstration, let's generate a simple table with a timestamp

$csec=date('i');
//$csec=3;
//echo "csec:".$csec;

$cseci=360-(($csec-15)*6);
if ($cseci>360){
	$cseci=$cseci-360;
}
//echo "cseci:".$cseci;

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];
}

function cieXYZtoAdobeRGB($X, $Y, $Z) {
    // Normalize XYZ values
    $X /= 1.0;
    $Y /= 1.0;
    $Z /= 1.0;

    // Transformation matrix from XYZ to Adobe RGB
    $matrix = [
        [ 2.04159, -0.56501, -0.34473],
        [-0.96924,  1.87597,  0.04156],
        [ 0.01344, -0.11836,  1.01517]
    ];

    // Linear transformation from XYZ to Adobe RGB
    $R = $matrix[0][0] * $X + $matrix[0][1] * $Y + $matrix[0][2] * $Z;
    $G = $matrix[1][0] * $X + $matrix[1][1] * $Y + $matrix[1][2] * $Z;
    $B = $matrix[2][0] * $X + $matrix[2][1] * $Y + $matrix[2][2] * $Z;

    // 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 Adobe RGB values
    $R = round($R * 255);
    $G = round($G * 255);
    $B = round($B * 255);

    // Return Adobe RGB color array
    return [$R, $G, $B];
}

function cieXYZtoP3RGB($X, $Y, $Z) {
    // Normalize XYZ values
    $X /= 1.0;
    $Y /= 1.0;
    $Z /= 1.0;

    // Transformation matrix from XYZ to Display P3 RGB
    $matrix = [
        [ 2.725394, -1.018662, -0.440185],
        [-0.795168,  1.781022,  0.015715],
        [ 0.041241, -0.126682,  1.272056]
    ];

    // Linear transformation from XYZ to Display P3 RGB
    $R = $matrix[0][0] * $X + $matrix[0][1] * $Y + $matrix[0][2] * $Z;
    $G = $matrix[1][0] * $X + $matrix[1][1] * $Y + $matrix[1][2] * $Z;
    $B = $matrix[2][0] * $X + $matrix[2][1] * $Y + $matrix[2][2] * $Z;

    // 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 Display P3 RGB values
    $R = round($R * 255);
    $G = round($G * 255);
    $B = round($B * 255);

    // Return Display P3 RGB color array
    return [$R, $G, $B];
}

/////sec section////////
$chrome=100;
$L=55;


if ($cseci>47){
	$L=55;
}
if ($cseci>53){
	$L=60;
}
if ($cseci>59){
	$L=65;
}

if ($cseci>65){
	$L=70;
}

if ($cseci>71){
	$L=75;
	//$chrome=85;
}
if ($cseci>77){
	$L=80;
	//$chrome=85;
}

if ($cseci>83){
	$L=85;
	//$chrome=87;
}
if ($cseci>89){
	$L=93;
	//$chrome=90;
}
if ($cseci>95){
	$L=93;
	//$chrome=87;
}
if ($cseci>101){
	$L=92;
	//$chrome=85;
}
if ($cseci>107){
	$L=90;
	//$chrome=85;
}

if ($cseci>113){
	$L=88;
	//$chrome=85;
}

if ($cseci>119){
	$L=85;
	//$chrome=85;
}

if ($cseci>125){
	$L=83;
	//$chrome=85;
}
if ($cseci>131){
	$L=80;
	//$chrome=85;
}

if ($cseci>137){
	$L=78;
	//$chrome=85;
}

if ($cseci>143){
	$L=75;
	//$chrome=85;
}

if ($cseci>149){
	$L=70;
	//$chrome=80;
}
if ($cseci>155){
	$L=68;
	//$chrome=80;
}
if ($cseci>161){
	$L=65;
	//$chrome=80;
}
if ($cseci>167){
	$L=63;
	//$chrome=80;
}
if ($cseci>173){
	$L=60;
	//$chrome=80;
}
if ($cseci>179){
	$L=58;
	//$chrome=80;
}
if ($cseci>185){
	$L=55;
	//$chrome=80;
}



$degree=deg2rad($cseci);
$a=cos($degree)*$chrome;
$b=sin($degree)*$chrome;

//echo "L a b:".$L."_".$a."_".$b;

$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);

$aRGB = cieXYZtoAdobeRGB($cieXYZ[0], $cieXYZ[1], $cieXYZ[2]);
$aR = $aRGB[0];
$aG = $aRGB[1];
$aB = $aRGB[2];
$asecHEX=RGBToHex($aR,$aG,$aB);

$pRGB = cieXYZtoP3RGB($cieXYZ[0], $cieXYZ[1], $cieXYZ[2]);
$pR = $pRGB[0];
$pG = $pRGB[1];
$pB = $pRGB[2];
$psecHEX=RGBToHex($pR,$pG,$aB);


echo "<table width='300' border='1' align='center'>";
echo "<tr>
<td bgcolor='".$secHEX."'><font color='cccccc' size='-1'>".$L.",".round($a,0).",".round($b,0)."<br>" .$sR.",".$sG.",".$sB."<br>" . date('i') ."</td>
<td bgcolor='".$asecHEX."'><font color='cccccc' size='-1'><br>" .$aR.",".$aG.",".$aB."<br>" . date('i') ."</td>
<td bgcolor='".$psecHEX."'><font color='cccccc' size='-1'><br>" .$pR.",".$pG.",".$pB."<br>" . date('i') ."</td>
</tr>";
echo "</table>";
?>