Pour éditer le wiki, il faut demander un compte à un Lapin !

Difference between revisions of "GenerationDePaletteDeCouleurs"

From Le L∞p's Wiki
Jump to: navigation, search
(generation de palette de couleur)
(generation de palette de couleur)
Line 8: Line 8:
  
 
<code>
 
<code>
\#!/usr/bin/perl
+
  #!/usr/bin/perl
  
print "<html> <head><title>palette</title></head> <body>\n";
+
  print "<html> <head><title>palette</title></head> <body>\n";
  
for $v1 ( 4,3 ) {
+
  for $v1 ( 4,3 ) {
  $v = $v1 / 4;
+
    $v = $v1 / 4;
  for $s1 ( 2 ) {
+
    for $s1 ( 2 ) {
    $s = $s1/2;
+
      $s = $s1/2;
      for $h1 (0,1,2,3,4,5,6,7,8,9,10,11) {
+
        for $h1 (0,1,2,3,4,5,6,7,8,9,10,11) {
      $h = $h1 * 30;
+
        $h = $h1 * 30;
      $ti = int($h/60) % 6;
+
        $ti = int($h/60) % 6;
      $f = $h/60 - $ti;
+
        $f = $h/60 - $ti;
      $l = $v * (1 - $s);
+
        $l = $v * (1 - $s);
      $m = $v * (1 - $f * $s);
+
        $m = $v * (1 - $f * $s);
      $n = $v * (1 - (1 - $f) * $s);
+
        $n = $v * (1 - (1 - $f) * $s);
      @r = ($v,$m,$l,$l,$n,$v);
+
        @r = ($v,$m,$l,$l,$n,$v);
      @g = ($n,$v,$v,$m,$l,$l);
+
        @g = ($n,$v,$v,$m,$l,$l);
      @b = ($l,$l,$n,$v,$v,$m);
+
        @b = ($l,$l,$n,$v,$v,$m);
      printf("<span style=\"background-color : #%.2x%.2x%.2x\">&nbsp;</span>\n",$r[$ti]*256,$g[$ti]*256,$b[$ti]*256);
+
        printf("<span style=\"background-color : #%.2x%.2x%.2x\">&nbsp;</span>\n",$r[$ti]*256,$g[$ti]*256,$b[$ti]*256);
 +
      }
 
     }
 
     }
 
   }
 
   }
}
 
  
print "</body></html>\n";
+
  print "</body></html>\n";
 
</code>
 
</code>

Revision as of 17:13, 20 May 2012

generation de palette de couleur

un petit script naif pour generer une palette de 24 couleurs, potentiellement adequate pour du graphing

Usage: ./palette.pl | sed 's/100/ff/g' > ./palette.html

Patches welcome

 #!/usr/bin/perl
 print "<html> <head><title>palette</title></head> <body>\n";
 for $v1 ( 4,3 ) {
   $v = $v1 / 4;
   for $s1 ( 2 ) {
     $s = $s1/2;
       for $h1 (0,1,2,3,4,5,6,7,8,9,10,11) {
       $h = $h1 * 30;
       $ti = int($h/60) % 6;
       $f = $h/60 - $ti;
       $l = $v * (1 - $s);
       $m = $v * (1 - $f * $s);
       $n = $v * (1 - (1 - $f) * $s);
       @r = ($v,$m,$l,$l,$n,$v);
       @g = ($n,$v,$v,$m,$l,$l);
       @b = ($l,$l,$n,$v,$v,$m);
       printf(" \n",$r[$ti]*256,$g[$ti]*256,$b[$ti]*256);
     }
   }
 }
 print "</body></html>\n";