Site web 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.
 
 
 
 

163 lines
2.9 KiB

  1. <?php
  2. if (!isset($_GET['clr']))
  3. $clr = sprintf('%06X', mt_rand(0, 0xFFFFFF));
  4. else
  5. $clr = htmlspecialchars($_GET['clr']);
  6. echo $clr;
  7. $hexcode = $clr;
  8. $redhex = substr($hexcode,0,2);
  9. $greenhex = substr($hexcode,2,2);
  10. $bluehex = substr($hexcode,4,2);
  11. $var_r = (hexdec($redhex)) / 255;
  12. $var_g = (hexdec($greenhex)) / 255;
  13. $var_b = (hexdec($bluehex)) / 255;
  14. $var_min = min($var_r,$var_g,$var_b);
  15. $var_max = max($var_r,$var_g,$var_b);
  16. $del_max = $var_max - $var_min;
  17. $l = ($var_max + $var_min) / 2;
  18. if ($del_max == 0) {
  19. $h = 0;
  20. $s = 0;
  21. } else {
  22. if ($l < 0.5) {
  23. $s = $del_max / ($var_max + $var_min);
  24. } else {
  25. $s = $del_max / (2 - $var_max - $var_min);
  26. };
  27. $del_r = ((($var_max - $var_r) / 6) + ($del_max / 2)) / $del_max;
  28. $del_g = ((($var_max - $var_g) / 6) + ($del_max / 2)) / $del_max;
  29. $del_b = ((($var_max - $var_b) / 6) + ($del_max / 2)) / $del_max;
  30. if ($var_r == $var_max) {
  31. $h = $del_b - $del_g;
  32. } elseif ($var_g == $var_max) {
  33. $h = (1 / 3) + $del_r - $del_b;
  34. } elseif ($var_b == $var_max) {
  35. $h = (2 / 3) + $del_g - $del_r;
  36. };
  37. if ($h < 0) {
  38. $h += 1;
  39. };
  40. if ($h > 1) {
  41. $h -= 1;
  42. };
  43. };
  44. $h2 = $h + 0.5;
  45. if ($h2 > 1) {
  46. $h2 -= 1;
  47. };
  48. if ($s == 0) {
  49. $r = $l * 255;
  50. $g = $l * 255;
  51. $b = $l * 255;
  52. } else {
  53. if ($l < 0.5) {
  54. $var_2 = $l * (1 + $s);
  55. } else {
  56. $var_2 = ($l + $s) - ($s * $l);
  57. };
  58. $var_1 = 2 * $l - $var_2;
  59. $r = 255 * hue_2_rgb($var_1,$var_2,$h2 + (1 / 3));
  60. $g = 255 * hue_2_rgb($var_1,$var_2,$h2);
  61. $b = 255 * hue_2_rgb($var_1,$var_2,$h2 - (1 / 3));
  62. };
  63. function hue_2_rgb($v1,$v2,$vh) {
  64. if ($vh < 0) {
  65. $vh += 1;
  66. };
  67. if ($vh > 1) {
  68. $vh -= 1;
  69. };
  70. if ((6 * $vh) < 1) {
  71. return ($v1 + ($v2 - $v1) * 6 * $vh);
  72. };
  73. if ((2 * $vh) < 1) {
  74. return ($v2);
  75. };
  76. if ((3 * $vh) < 2) {
  77. return ($v1 + ($v2 - $v1) * ((2 / 3 - $vh) * 6));
  78. };
  79. return ($v1);
  80. };
  81. $rhex = sprintf("%02X",round($r));
  82. $ghex = sprintf("%02X",round($g));
  83. $bhex = sprintf("%02X",round($b));
  84. $rgbhex = $rhex . $ghex . $bhex;
  85. ?>
  86. <!-- Code source : https://code.antopie.org/miraty/web/src/branch/master/clr.php -->
  87. <!DOCTYPE html>
  88. <html>
  89. <head>
  90. <meta content="UTF-8">
  91. <title>
  92. <?php
  93. echo "#" . $clr;
  94. if (isset($_GET['txt']))
  95. echo " " . htmlspecialchars($_GET['txt']);
  96. ?>
  97. </title>
  98. <style>
  99. body {
  100. background-color: <?php echo "#" . $clr; ?>;
  101. }
  102. #txt {
  103. font-family: "Ubuntu", sans-serif;
  104. font-size: 50px;
  105. color: <?php echo "#" . $rgbhex; ?>;
  106. padding: 10px;
  107. position: absolute;
  108. text-align: center;
  109. margin-left: auto;
  110. margin-right: auto;
  111. margin-bottom: auto;
  112. margin-top: auto;
  113. width: 90%;
  114. left: 50%;
  115. top: 50%;
  116. transform: translate(-50%,-50%);
  117. }
  118. </style>
  119. </head>
  120. <body>
  121. <?php if (isset($_GET['txt'])) { ?>
  122. <div id="txt"><?php echo htmlspecialchars($_GET['txt']); ?></div>
  123. <?php } ?>
  124. </body>
  125. </html>