From 7d66716d6f6059ef6b89f8e3cb56ca48dfc91811 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Wed, 26 Sep 2012 20:33:48 +0000 Subject: [PATCH] Correção na geração do número de cores --- classesphp/class.palette.php | 33 +++++++++++++++++++++++++++++++++ symbols/colourramp/geradat.php | 33 ++++++++++++++++++++++----------- 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/classesphp/class.palette.php b/classesphp/class.palette.php index 5f47196..a6ffb1f 100644 --- a/classesphp/class.palette.php +++ b/classesphp/class.palette.php @@ -146,6 +146,39 @@ $numSteps - número de cores finais $conteudo = fread ($handle, filesize ($arq)); fclose ($handle); $cores = unserialize($conteudo); + if(count($cores) < 250){ + $arq = $locaplic."/symbols/colourramp/".$codigo.".dat"; + $handle = fopen ($arq, "r"); + $linhas = array(); + $cores = array(); + while (!feof ($handle)) { + $buffer = fgets($handle); + $buffer = str_replace(" "," ",$buffer); + $buffer = str_replace(" "," ",$buffer); + $buffer = str_replace(" "," ",$buffer); + $buffer = str_replace(" "," ",$buffer); + $ts = explode(" ",$buffer); + $linha = array(); + foreach ($ts as $t){ + if($t != ""){ + $linha[] = intval($t); + } + } + //var_dump($linha); + //if($linha[1]) + $cores[$linha[0]] = array("r"=>$linha[1],"g"=>$linha[2],"b"=>$linha[3]); + //if($linha[4]) + $cores[$linha[4]] = array("r"=>$linha[5],"g"=>$linha[6],"b"=>$linha[7]); + //if($linha[8]) + $cores[$linha[8]] = array("r"=>$linha[9],"g"=>$linha[10],"b"=>$linha[11]); + //if($linha[12]) + $cores[$linha[12]] = array("r"=>$linha[13],"g"=>$linha[14],"b"=>$linha[15]); + } + fclose ($handle); + rsort($cores); + array_pop($cores); + } + //echo count($cores);exit; if($ncores == 0) {return $cores;} $coresfinais = array(); diff --git a/symbols/colourramp/geradat.php b/symbols/colourramp/geradat.php index 661d976..47630a7 100644 --- a/symbols/colourramp/geradat.php +++ b/symbols/colourramp/geradat.php @@ -15,39 +15,50 @@ for($i=1;$i<23;$i++) var_dump(unserialize($conteudo)); */ //serialize - + //echo $i.".dat"; $handle = fopen ($i.".dat", "r"); $linhas = array(); $r = array(); - while (!feof ($handle)) { $buffer = fgets($handle); + $buffer = str_replace(" "," ",$buffer); + $buffer = str_replace(" "," ",$buffer); + $buffer = str_replace(" "," ",$buffer); + $buffer = str_replace(" "," ",$buffer); $ts = explode(" ",$buffer); $linha = array(); foreach ($ts as $t){ - if(!empty($t) || $t == "0") - {$linha[] = intval($t);} + if($t != ""){ + $linha[] = intval($t); + } } //var_dump($linha); - if($linha[1]) + //if($linha[1]) $r[$linha[0]] = array("r"=>$linha[1],"g"=>$linha[2],"b"=>$linha[3]); - if($linha[4]) + //if($linha[4]) $r[$linha[4]] = array("r"=>$linha[5],"g"=>$linha[6],"b"=>$linha[7]); - if($linha[8]) + //if($linha[8]) $r[$linha[8]] = array("r"=>$linha[9],"g"=>$linha[10],"b"=>$linha[11]); - if($linha[12]) + //if($linha[12]) $r[$linha[12]] = array("r"=>$linha[13],"g"=>$linha[14],"b"=>$linha[15]); } fclose ($handle); rsort($r); + array_pop($r); + //var_dump($r); if (file_exists($arq.".cores")) {unlink($arq.".cores");} - $fp = fopen($arq.".cores","w"); $rr = serialize($r); + $fp = fopen($arq.".cores","w"); fwrite($fp,$rr); fclose($fp); - -} + echo $arq.".cores
"; + $handle = fopen ($arq.".cores", "r"); + $conteudo = fread ($handle, filesize ($arq.".cores")); + fclose ($handle); + $cores = unserialize($conteudo); + echo count($cores)."
"; +} //var_dump($r); ?> \ No newline at end of file -- libgit2 0.21.2