===== Safe Colours in the Web ===== ==== The colour scheme ==== echo '

' . "\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 "\n"; $GRUEN = sprintf("%x", $G); if ($G >= 0xc) { $tf = "#000"; } for ($B = 0x0; $B <= 0xf; $B +=0x3) { $BLAU = sprintf("%x", $B); echo ' \n"; } // for $B echo " \n"; } // for $G } // for $R echo "
'; echo "# $ROT $GRUEN $BLAU
\n

"; Colour numbers are given in XHTML style; for HTML style, you may "double" the values, so ''#c3f'' becomes ''#cc33ff''. ==== and the source code: ==== echo '' . "\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 "\n"; $GRUEN = sprintf("%x", $G); if ($G >= 0xc) { $tf = "#000"; } for ($B = 0x0; $B <= 0xf; $B +=0x3) { $BLAU = sprintf("%x", $B); echo ' \n"; } // for $B echo " \n"; } // for $G } // for $R echo "
'; echo "# $ROT $GRUEN $BLAU
\n";
Of course the "central" ''echo'' invocation can be written another way: echo ' '; 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)