Jump to content

Color chart


nuxy

Recommended Posts

Hello there,

 

I was just thinking that I wanted to make an color chart, that you would be able to give a color code for text, and the script will display the background color code from a cell.

Bit confusing, but never the less, this is just some personal think I would like to make for myself.

 

I have worked out a way to display all the colors, based on the number of characters in a color code, versus the available character you can use.

But I wanted to know if I could in a way, group the colors.

Like shades of red goes together, shades of green, blue, yellow, white and so forth.

 

I'm not an expert with what codes produce what colors, so this is a bit frustrating for me.

Here is my current script.

<?php
  $codes = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F');
  $read = array();
  echo '<table style="background:#1d1d1d;border-spacing:5px"><tr>';
  for ($s = 0; $s <= 1536; $s++) {
      $c++;
      while (strlen($string) != 6) {
          $string .= $codes[rand(0, 16)];
      }
      if (!in_array($string, $read)) {
          echo '<td style="font-family:tahoma;font-size:9px;color:#' . $_GET['c'] . ';text-align:center;padding:5px;width:40px;heigth:20px;background-color: #' . $string . ';">#' . $string . '</td> ';
          $read[] = $string;
          unset($string);
      }
      if ($c == 20) {
          echo '
   </tr><tr>';
          $c = 0;
      }
  }
  echo '</table>';
?>

 

Anyone have any ideas?

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/77125-color-chart/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.