Guest User

Untitled

a guest
Oct 17th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. function giveMSXColor($i) {
  2.     $col=str_pad(decbin($i),8,'0',STR_PAD_LEFT);
  3.     $r=str_pad(dechex(round(bindec(substr($col,0,3))*(255/7))),2,'0',STR_PAD_LEFT);
  4.     $g=str_pad(dechex(round(bindec(substr($col,3,3))*(255/7))),2,'0',STR_PAD_LEFT);
  5.     $b=str_pad(dechex(round(bindec(substr($col,6,2).'0')*(255/7))),2,'0',STR_PAD_LEFT);
  6.    
  7.     #print $b.'<Br/>';
  8.     return '#'.$g.$r.$b;
  9. }
  10.  
  11. #echo (giveMSXColor(128));
  12.  
  13. echo('<table>');
  14. for ($y=0;$y<16;$y++) {
  15.     echo('<tr>');
  16.         for ($x=0;$x<16;$x++) {
  17.         $col=giveMSXColor($y*16+$x);
  18.             echo('<td style="background:'.$col.';font-size:10px;">'.(string)($y*16+$x).'-'.$col.'</td>');
  19.         }
  20.     echo('</tr>');
  21. }
Add Comment
Please, Sign In to add comment