User Tools

Site Tools


comp:en:farbtafel
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


comp:en:farbtafel [2008-08-24 0343] (current) – created werner
Line 1: Line 1:
 +===== Safe Colours in the Web =====
  
 +==== The colour scheme ====
 +
 +<php>
 +  echo '</p><table summary="safe colours in the Web">' . "\n";
 +  for ($R = 0x0; $R <= 0xf; $R += 0x3) {
 +    $ROT = sprintf("%x", $R);
 +    $tf = ($R == 0xf) ? "#000" : "#fff";
 +    for ($G = 0x0; $G <= 0xf; $G += 0x3) {
 +      echo "<tr>\n";
 +      $GRUEN = sprintf("%x", $G);
 +      if ($G >= 0xc) { 
 +        $tf = "#000"; 
 +      }
 +      for ($B = 0x0; $B <= 0xf; $B +=0x3) {
 +        $BLAU = sprintf("%x", $B);
 +        echo '      <td style="background-color:#' . "$ROT$GRUEN$BLAU" . '; color:' . "$tf" . ';" width="100" align="center">';
 +        echo "# $ROT $GRUEN $BLAU</td>\n";
 +      } // for $B
 +      echo "    </tr>\n";
 +    } // for $G
 +  } // for $R
 +  echo "</table>\n<p>";
 +</php>
 +
 +Colour numbers are given in XHTML style; for HTML style, you may "double" the values, so ''#c3f'' becomes ''#cc33ff''.
 +
 +==== and the source code: ====
 +<code php>
 +echo '<table summary="safe colours in the Web">' . "\n";
 +for ($R = 0x0; $R <= 0xf; $R += 0x3) {
 +  $ROT = sprintf("%x", $R);
 +  $tf = ($R == 0xf) ? "#000" : "#fff";
 +  for ($G = 0x0; $G <= 0xf; $G += 0x3) {
 +    echo "<tr>\n";
 +    $GRUEN = sprintf("%x", $G);
 +    if ($G >= 0xc) { $tf = "#000"; }
 +    for ($B = 0x0; $B <= 0xf; $B +=0x3) {
 +      $BLAU = sprintf("%x", $B);
 +      echo '      <td style="background-color:#' . "$ROT$GRUEN$BLAU"
 +           '; color:' . "$tf" . ';" width="100" align="center">';
 +      echo "# $ROT $GRUEN $BLAU</td>\n";
 +    } // for $B
 +    echo "    </tr>\n";
 +  } // for $G
 +} // for $R
 +echo "</table>\n";
 +</code>
 +
 +Of course the "central" ''echo'' invocation can be written another way:
 +<code php>
 +      echo '      <td style="background-color:#',
 +           $ROT, $GRUEN, $BLAU, '; color:', $tf, 
 +           ';" width="100" align="center">';
 +</code>
 +
 +If you want to change the output so that HTML values are displayed, you have to make following modifications:
 +  * the condition for the loop reads ''%%<%%= 0xff''
 +  * the loop counter is incremented with ''+= %%0x33%%''
 +  * the output changes to ''%02x'' (results in 00 bis ff) or ''%02X'' (results in 00 bis FF)
comp/en/farbtafel.txt · Last modified: 2008-08-24 0343 by werner

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki