L'ancien dépot du générateur de sites d'Antopie https://antopie.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 

160 lines
2.9 KiB

<?php
if (isset($_GET['clr']))
$clr = htmlspecialchars($_GET['clr']);
else
$clr = sprintf('%06X', mt_rand(0, 0xFFFFFF));
$hexcode = $clr;
$redhex = substr($hexcode,0,2);
$greenhex = substr($hexcode,2,2);
$bluehex = substr($hexcode,4,2);
$var_r = (hexdec($redhex)) / 255;
$var_g = (hexdec($greenhex)) / 255;
$var_b = (hexdec($bluehex)) / 255;
$var_min = min($var_r,$var_g,$var_b);
$var_max = max($var_r,$var_g,$var_b);
$del_max = $var_max - $var_min;
$l = ($var_max + $var_min) / 2;
if ($del_max == 0) {
$h = 0;
$s = 0;
} else {
if ($l < 0.5) {
$s = $del_max / ($var_max + $var_min);
} else {
$s = $del_max / (2 - $var_max - $var_min);
};
$del_r = ((($var_max - $var_r) / 6) + ($del_max / 2)) / $del_max;
$del_g = ((($var_max - $var_g) / 6) + ($del_max / 2)) / $del_max;
$del_b = ((($var_max - $var_b) / 6) + ($del_max / 2)) / $del_max;
if ($var_r == $var_max) {
$h = $del_b - $del_g;
} elseif ($var_g == $var_max) {
$h = (1 / 3) + $del_r - $del_b;
} elseif ($var_b == $var_max) {
$h = (2 / 3) + $del_g - $del_r;
};
if ($h < 0) {
$h += 1;
};
if ($h > 1) {
$h -= 1;
};
};
$h2 = $h + 0.5;
if ($h2 > 1) {
$h2 -= 1;
};
if ($s == 0) {
$r = $l * 255;
$g = $l * 255;
$b = $l * 255;
} else {
if ($l < 0.5) {
$var_2 = $l * (1 + $s);
} else {
$var_2 = ($l + $s) - ($s * $l);
};
$var_1 = 2 * $l - $var_2;
$r = 255 * hue_2_rgb($var_1,$var_2,$h2 + (1 / 3));
$g = 255 * hue_2_rgb($var_1,$var_2,$h2);
$b = 255 * hue_2_rgb($var_1,$var_2,$h2 - (1 / 3));
};
function hue_2_rgb($v1,$v2,$vh) {
if ($vh < 0) {
$vh += 1;
};
if ($vh > 1) {
$vh -= 1;
};
if ((6 * $vh) < 1) {
return ($v1 + ($v2 - $v1) * 6 * $vh);
};
if ((2 * $vh) < 1) {
return ($v2);
};
if ((3 * $vh) < 2) {
return ($v1 + ($v2 - $v1) * ((2 / 3 - $vh) * 6));
};
return ($v1);
};
$rhex = sprintf("%02X",round($r));
$ghex = sprintf("%02X",round($g));
$bhex = sprintf("%02X",round($b));
$rgbhex = $rhex . $ghex . $bhex;
?>
<!-- Code source : https://code.antopie.org/miraty/web/src/branch/master/antopie/clr.php -->
<!DOCTYPE html>
<html>
<head>
<meta content="UTF-8">
<title>
<?php
echo "#" . $clr;
if (isset($_GET['txt']))
echo " " . htmlspecialchars($_GET['txt']);
?>
</title>
<style>
body {
background-color: <?php echo "#" . $clr; ?>;
}
#txt {
font-family: system-ui, sans-serif;
font-size: 50px;
color: <?php echo "#" . $rgbhex; ?>;
padding: 10px;
position: absolute;
text-align: center;
margin-left: auto;
margin-right: auto;
margin-bottom: auto;
margin-top: auto;
width: 90%;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
}
</style>
</head>
<body>
<?php if (isset($_GET['txt'])) { ?>
<div id="txt"><?php echo htmlspecialchars($_GET['txt']); ?></div>
<?php } ?>
</body>
</html>