Commit 7d66716d6f6059ef6b89f8e3cb56ca48dfc91811

Authored by Edmar Moretti
1 parent 33e39436

Correção na geração do número de cores

classesphp/class.palette.php
@@ -146,6 +146,39 @@ $numSteps - número de cores finais @@ -146,6 +146,39 @@ $numSteps - número de cores finais
146 $conteudo = fread ($handle, filesize ($arq)); 146 $conteudo = fread ($handle, filesize ($arq));
147 fclose ($handle); 147 fclose ($handle);
148 $cores = unserialize($conteudo); 148 $cores = unserialize($conteudo);
  149 + if(count($cores) < 250){
  150 + $arq = $locaplic."/symbols/colourramp/".$codigo.".dat";
  151 + $handle = fopen ($arq, "r");
  152 + $linhas = array();
  153 + $cores = array();
  154 + while (!feof ($handle)) {
  155 + $buffer = fgets($handle);
  156 + $buffer = str_replace(" "," ",$buffer);
  157 + $buffer = str_replace(" "," ",$buffer);
  158 + $buffer = str_replace(" "," ",$buffer);
  159 + $buffer = str_replace(" "," ",$buffer);
  160 + $ts = explode(" ",$buffer);
  161 + $linha = array();
  162 + foreach ($ts as $t){
  163 + if($t != ""){
  164 + $linha[] = intval($t);
  165 + }
  166 + }
  167 + //var_dump($linha);
  168 + //if($linha[1])
  169 + $cores[$linha[0]] = array("r"=>$linha[1],"g"=>$linha[2],"b"=>$linha[3]);
  170 + //if($linha[4])
  171 + $cores[$linha[4]] = array("r"=>$linha[5],"g"=>$linha[6],"b"=>$linha[7]);
  172 + //if($linha[8])
  173 + $cores[$linha[8]] = array("r"=>$linha[9],"g"=>$linha[10],"b"=>$linha[11]);
  174 + //if($linha[12])
  175 + $cores[$linha[12]] = array("r"=>$linha[13],"g"=>$linha[14],"b"=>$linha[15]);
  176 + }
  177 + fclose ($handle);
  178 + rsort($cores);
  179 + array_pop($cores);
  180 + }
  181 + //echo count($cores);exit;
149 if($ncores == 0) 182 if($ncores == 0)
150 {return $cores;} 183 {return $cores;}
151 $coresfinais = array(); 184 $coresfinais = array();
symbols/colourramp/geradat.php
@@ -15,39 +15,50 @@ for($i=1;$i&lt;23;$i++) @@ -15,39 +15,50 @@ for($i=1;$i&lt;23;$i++)
15 var_dump(unserialize($conteudo)); 15 var_dump(unserialize($conteudo));
16 */ 16 */
17 //serialize 17 //serialize
18 - 18 +
19 //echo $i.".dat"; 19 //echo $i.".dat";
20 $handle = fopen ($i.".dat", "r"); 20 $handle = fopen ($i.".dat", "r");
21 $linhas = array(); 21 $linhas = array();
22 $r = array(); 22 $r = array();
23 -  
24 while (!feof ($handle)) { 23 while (!feof ($handle)) {
25 $buffer = fgets($handle); 24 $buffer = fgets($handle);
  25 + $buffer = str_replace(" "," ",$buffer);
  26 + $buffer = str_replace(" "," ",$buffer);
  27 + $buffer = str_replace(" "," ",$buffer);
  28 + $buffer = str_replace(" "," ",$buffer);
26 $ts = explode(" ",$buffer); 29 $ts = explode(" ",$buffer);
27 $linha = array(); 30 $linha = array();
28 foreach ($ts as $t){ 31 foreach ($ts as $t){
29 - if(!empty($t) || $t == "0")  
30 - {$linha[] = intval($t);} 32 + if($t != ""){
  33 + $linha[] = intval($t);
  34 + }
31 } 35 }
32 //var_dump($linha); 36 //var_dump($linha);
33 - if($linha[1]) 37 + //if($linha[1])
34 $r[$linha[0]] = array("r"=>$linha[1],"g"=>$linha[2],"b"=>$linha[3]); 38 $r[$linha[0]] = array("r"=>$linha[1],"g"=>$linha[2],"b"=>$linha[3]);
35 - if($linha[4]) 39 + //if($linha[4])
36 $r[$linha[4]] = array("r"=>$linha[5],"g"=>$linha[6],"b"=>$linha[7]); 40 $r[$linha[4]] = array("r"=>$linha[5],"g"=>$linha[6],"b"=>$linha[7]);
37 - if($linha[8]) 41 + //if($linha[8])
38 $r[$linha[8]] = array("r"=>$linha[9],"g"=>$linha[10],"b"=>$linha[11]); 42 $r[$linha[8]] = array("r"=>$linha[9],"g"=>$linha[10],"b"=>$linha[11]);
39 - if($linha[12]) 43 + //if($linha[12])
40 $r[$linha[12]] = array("r"=>$linha[13],"g"=>$linha[14],"b"=>$linha[15]); 44 $r[$linha[12]] = array("r"=>$linha[13],"g"=>$linha[14],"b"=>$linha[15]);
41 } 45 }
42 fclose ($handle); 46 fclose ($handle);
43 rsort($r); 47 rsort($r);
  48 + array_pop($r);
  49 + //var_dump($r);
44 if (file_exists($arq.".cores")) 50 if (file_exists($arq.".cores"))
45 {unlink($arq.".cores");} 51 {unlink($arq.".cores");}
46 - $fp = fopen($arq.".cores","w");  
47 $rr = serialize($r); 52 $rr = serialize($r);
  53 + $fp = fopen($arq.".cores","w");
48 fwrite($fp,$rr); 54 fwrite($fp,$rr);
49 fclose($fp); 55 fclose($fp);
50 -  
51 -} 56 + echo $arq.".cores<br>";
  57 + $handle = fopen ($arq.".cores", "r");
  58 + $conteudo = fread ($handle, filesize ($arq.".cores"));
  59 + fclose ($handle);
  60 + $cores = unserialize($conteudo);
  61 + echo count($cores)."<br>";
  62 +}
52 //var_dump($r); 63 //var_dump($r);
53 ?> 64 ?>
54 \ No newline at end of file 65 \ No newline at end of file