Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Web Safe Colors ====== {{https://raw.githubusercontent.com/yusukekamiyamane/fugue-icons/master/bonus/icons-32/color-swatch.png?nolink }} Questa pagina elenca i 216 colori "sicuri" che possono essere visualizzati senza problemi su macchine hanno schede video a 8-bit (max 256 colori). Per ricavare velocemente l'elenco dei 216 colori è possibile usare il seguente script PHP che può facilmente essere adattato per un'altro linguaggio, come ad esempio JavaScript. <code php> $hex = array('00', '33', '66', '99', 'CC', 'FF'); $colors = array(); foreach ($hex as $col1) { foreach ($hex as $col2) { foreach ($hex as $col3) { $colors[] = "$col1$col2$col3"; } } } </code> ===== Tabella dei colori ===== <php> $hex = array('00', '33', '66', '99', 'CC', 'FF'); $colors = array(); foreach ($hex as $c1) { foreach ($hex as $c2) { foreach ($hex as $c3) { $colors[] = array('hex' => "$c1$c2$c3", 'dec' => hexdec($c1).' '.hexdec($c2).' '.hexdec($c3)); } } } $i=0; $x=0; echo '<table style="width:100%; font-family:monospace; text-align:center"><tr><td> </td><td>'. implode('</td><td>', $hex) .'</td></tr><tr>'; foreach ($colors as $color) { $c_hex = $color['hex']; $c_dec = $color['dec']; $b_color = ((int)(hexdec(substr($color['hex'], 0,2)) < 102) ? 'white' : 'black'); $test = hexdec(substr($color['hex'], 0,2)); $x_hex = substr($color['hex'], 0,2); $y_hex = substr($color['hex'], 4,2); if ($i>1 && ($i%6) == 0) { if ($x==6) { $x=0; } echo '<td>'.$hex[$x].'</td>'; $x++; } if (($i%6) == 0) { echo '</tr><tr>'; if ($x_tmp !== $x_hex) { echo '<td style="vertical-align:middle" rowspan="6">'.$x_hex.'</td>'; } } echo "<td style=\"width:16%; color:$b_color; background:#$c_hex;\">#$c_hex<br/>$c_dec</td>"; $i++; $x_tmp = $x_hex; } echo '<td>FF</td></tr></table>'; </php> {{tag>programming web colors php css}} ~~NOCACHE~~ programming/web_safe_colors.txt Last modified: 9 years agoby Giuseppe Di Terlizzi Log In