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)
m (+cat)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== generation de palette de couleur ==
+
Un petit script naif pour generer une palette de 24 couleurs, potentiellement adequate pour du graphing
 
+
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
 
Usage: ./palette.pl | sed 's/100/ff/g' > ./palette.html
Line 8: Line 6:
  
 
<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 ) {
 
+
    $v = $v1 / 4;
for $v1 ( 4,3 ) {
+
    for $s1 ( 2 ) {
  $v = $v1 / 4;
+
      $s = $s1/2;
  for $s1 ( 2 ) {
+
        for $h1 (0,1,2,3,4,5,6,7,8,9,10,11) {
    $s = $s1/2;
+
        $h = $h1 * 30;
      for $h1 (0,1,2,3,4,5,6,7,8,9,10,11) {
+
        $ti = int($h/60) % 6;
      $h = $h1 * 30;
+
        $f = $h/60 - $ti;
      $ti = int($h/60) % 6;
+
        $l = $v * (1 - $s);
      $f = $h/60 - $ti;
+
        $m = $v * (1 - $f * $s);
      $l = $v * (1 - $s);
+
        $n = $v * (1 - (1 - $f) * $s);
      $m = $v * (1 - $f * $s);
+
        @r = ($v,$m,$l,$l,$n,$v);
      $n = $v * (1 - (1 - $f) * $s);
+
        @g = ($n,$v,$v,$m,$l,$l);
      @r = ($v,$m,$l,$l,$n,$v);
+
        @b = ($l,$l,$n,$v,$v,$m);
      @g = ($n,$v,$v,$m,$l,$l);
+
        printf("&lt;span style=\"background-color : #%.2x%.2x%.2x\"&gt;&amp;nbsp;&lt;/span&gt;\n",$r[$ti]*256,$g[$ti]*256,$b[$ti]*256);
      @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);
+
 
     }
 
     }
 
   }
 
   }
}
+
  print "</body></html>\n";
 +
</code>
  
print "</body></html>\n";
+
[[Category:Documentation]]
</code>
+

Latest revision as of 22:31, 12 December 2012

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("<span style=\"background-color : #%.2x%.2x%.2x\">&nbsp;</span>\n",$r[$ti]*256,$g[$ti]*256,$b[$ti]*256);
     }
   }
 }
 print "</body></html>\n";