| @ -586,7 +586,7 @@ class blockchain | |||||
| ]; | ]; | ||||
| $color = $couleur; | $color = $couleur; | ||||
| if (($color == -1) || ($color > (count($color_tab)-1))) $color = rand(0,count($color_tab)-1); | |||||
| if (($color == -1) || ($color > (count($color_tab)-1))) $color = $the_block->nonce % count($color_tab); | |||||
| // Rajout des HASHES | // Rajout des HASHES | ||||
| $white = imagecolorallocate($vImage, 254, 254, 254); | $white = imagecolorallocate($vImage, 254, 254, 254); | ||||
| @ -29,35 +29,22 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB']; | if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB']; | ||||
| if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | ||||
| // Une chance sur deux d'inverser entre fg et bg | |||||
| if (rand(0,100) < 50) { | |||||
| $fond = $vBgColor; | |||||
| $couleur = $vFgColor; | |||||
| $fondRGB = $vBgRGB; | |||||
| $couleurRGB = $vFgRGB; | |||||
| } else { | |||||
| $fond = $vFgColor; | |||||
| $couleur = $vBgColor; | |||||
| $fondRGB = $vFgRGB; | |||||
| $couleurRGB = $vBgRGB; | |||||
| } | |||||
| // Remplir le fond | // Remplir le fond | ||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond); | |||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $vFgColor); | |||||
| // Dégradé de 360 couleurs entre la couleur de dessin et le blanc | // Dégradé de 360 couleurs entre la couleur de dessin et le blanc | ||||
| $vColor = getGDcolorGradientArray($vImage, 360, $couleurRGB, $fondRGB, $alpha); | |||||
| $nbColor = 360; | |||||
| $vColor = getGDcolorGradientArray($vImage, $nbColor, $vBgRGB, $vFgRGB, $alpha); | |||||
| // Récup des données | // Récup des données | ||||
| $data = blockchain::getTransactionData($the_block, $type); | $data = blockchain::getTransactionData($the_block, $type); | ||||
| $n_data = count($data); | |||||
| $xc = $x + ($width / 2); | $xc = $x + ($width / 2); | ||||
| $yc = $y + ($height / 2); | $yc = $y + ($height / 2); | ||||
| foreach($data as $transaction) | foreach($data as $transaction) | ||||
| { | { | ||||
| for($i=0;$i<360;$i++) | |||||
| for($i=0;$i<$nbColor;$i++) | |||||
| { | { | ||||
| $valeur = hexdec($transaction['hash'][$i%TX_HASH_LEN]); | $valeur = hexdec($transaction['hash'][$i%TX_HASH_LEN]); | ||||
| if ($valeur != 0) $valeur += $valeur - 8; | if ($valeur != 0) $valeur += $valeur - 8; | ||||
| @ -29,24 +29,11 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB']; | if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB']; | ||||
| if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | ||||
| // Une chance sur deux d'inverser entre fg et bg | |||||
| if (rand(0,100) < 50) { | |||||
| $fond = $vBgColor; | |||||
| $couleur = $vFgColor; | |||||
| $fondRGB = $vBgRGB; | |||||
| $couleurRGB = $vFgRGB; | |||||
| } else { | |||||
| $fond = $vFgColor; | |||||
| $couleur = $vBgColor; | |||||
| $fondRGB = $vFgRGB; | |||||
| $couleurRGB = $vBgRGB; | |||||
| } | |||||
| // Remplir le fond | // Remplir le fond | ||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond); | |||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $vFgColor); | |||||
| // Dégradé de 360 couleurs entre la couleur de dessin et le blanc | // Dégradé de 360 couleurs entre la couleur de dessin et le blanc | ||||
| $vColor = getGDcolorGradientArray($vImage, 360, $couleurRGB, $fondRGB, $alpha); | |||||
| $vColor = getGDcolorGradientArray($vImage, 360, $vBgRGB, $vBgRGB, $alpha); | |||||
| // Récup des données | // Récup des données | ||||
| $data = blockchain::getTransactionData($the_block, $type); | $data = blockchain::getTransactionData($the_block, $type); | ||||
| @ -63,7 +50,8 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| for($i=0;$i<TX_HASH_LEN;$i++) | for($i=0;$i<TX_HASH_LEN;$i++) | ||||
| { | { | ||||
| $valeur = hexdec($transaction['hash'][$i]) - 8; | $valeur = hexdec($transaction['hash'][$i]) - 8; | ||||
| $r = $r0+($valeur*rand(0,3)); | |||||
| $r = $valeur * $n_data; | |||||
| $r = $r0+($valeur*($r % 6)); | |||||
| $xi = floor($xc + $r*cos(deg2rad($i*(360/TX_HASH_LEN)))); | $xi = floor($xc + $r*cos(deg2rad($i*(360/TX_HASH_LEN)))); | ||||
| $yi = floor($yc + $r*sin(deg2rad($i*(360/TX_HASH_LEN)))); | $yi = floor($yc + $r*sin(deg2rad($i*(360/TX_HASH_LEN)))); | ||||
| @ -28,21 +28,8 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB']; | if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB']; | ||||
| if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | ||||
| // Une chance sur deux d'inverser entre fg et bg | |||||
| if (rand(0,100) < 50) { | |||||
| $fond = $vBgColor; | |||||
| $couleur = $vFgColor; | |||||
| $fondRGB = $vBgRGB; | |||||
| $couleurRGB = $vFgRGB; | |||||
| } else { | |||||
| $fond = $vFgColor; | |||||
| $couleur = $vBgColor; | |||||
| $fondRGB = $vFgRGB; | |||||
| $couleurRGB = $vBgRGB; | |||||
| } | |||||
| // Remplir le fond | // Remplir le fond | ||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond); | |||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $vFgColor); | |||||
| // Récup des données | // Récup des données | ||||
| $data = blockchain::getTransactionData($the_block, $type); | $data = blockchain::getTransactionData($the_block, $type); | ||||
| @ -56,7 +43,7 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| if ($nb < 5) $alpha = 0; | if ($nb < 5) $alpha = 0; | ||||
| // Dégradé de 360 couleurs entre la couleur de dessin et le blanc | // Dégradé de 360 couleurs entre la couleur de dessin et le blanc | ||||
| $vColor = getGDcolorGradientArray($vImage, 360, $couleurRGB, $fondRGB, $alpha); | |||||
| $vColor = getGDcolorGradientArray($vImage, 360, $vBgRGB, $vBgRGB, $alpha); | |||||
| // Un calculateur de Spline | // Un calculateur de Spline | ||||
| $oCurve = new CubicSplines(); | $oCurve = new CubicSplines(); | ||||
| @ -71,7 +58,7 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| { | { | ||||
| // Un coef aléatoire | // Un coef aléatoire | ||||
| $coef = 0.1; | $coef = 0.1; | ||||
| $c = rand(0,10); | |||||
| $c = $transaction['value']%10; | |||||
| if ($c > 5) $coef = 0.3; | if ($c > 5) $coef = 0.3; | ||||
| if ($c > 7) $coef = 0.8; | if ($c > 7) $coef = 0.8; | ||||
| if ($c > 9) $coef = 1.2; | if ($c > 9) $coef = 1.2; | ||||
| @ -29,24 +29,11 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB']; | if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB']; | ||||
| if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | ||||
| // Une chance sur deux d'inverser entre fg et bg | |||||
| if (rand(0,100) < 50) { | |||||
| $fond = $vBgColor; | |||||
| $couleur = $vFgColor; | |||||
| $fondRGB = $vBgRGB; | |||||
| $couleurRGB = $vFgRGB; | |||||
| } else { | |||||
| $fond = $vFgColor; | |||||
| $couleur = $vBgColor; | |||||
| $fondRGB = $vFgRGB; | |||||
| $couleurRGB = $vBgRGB; | |||||
| } | |||||
| // Remplir le fond | // Remplir le fond | ||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond); | |||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $vFgColor); | |||||
| // Dégradé de 360 couleurs entre la couleur de dessin et le blanc | // Dégradé de 360 couleurs entre la couleur de dessin et le blanc | ||||
| $vColor = getGDcolorGradientArray($vImage, 360, $couleurRGB, $fondRGB, $alpha); | |||||
| $vColor = getGDcolorGradientArray($vImage, 360, $vBgRGB, $vFgRGB, $alpha); | |||||
| // Récup des données | // Récup des données | ||||
| $data = blockchain::getTransactionData($the_block, $type); | $data = blockchain::getTransactionData($the_block, $type); | ||||
| @ -28,21 +28,8 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB']; | if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB']; | ||||
| if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | ||||
| // Une chance sur deux d'inverser entre fg et bg | |||||
| if (rand(0,100) < 50) { | |||||
| $fond = $vBgColor; | |||||
| $couleur = $vFgColor; | |||||
| $fondRGB = $vBgRGB; | |||||
| $couleurRGB = $vFgRGB; | |||||
| } else { | |||||
| $fond = $vFgColor; | |||||
| $couleur = $vBgColor; | |||||
| $fondRGB = $vFgRGB; | |||||
| $couleurRGB = $vBgRGB; | |||||
| } | |||||
| // Remplir le fond | // Remplir le fond | ||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond); | |||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $vFgColor); | |||||
| // Récup des données | // Récup des données | ||||
| $data = blockchain::getTransactionData($the_block, $type); | $data = blockchain::getTransactionData($the_block, $type); | ||||
| @ -66,7 +53,7 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| if ($nb < 5) $alpha = 0; | if ($nb < 5) $alpha = 0; | ||||
| // Dégradé de 360 couleurs entre la couleur de dessin et le blanc | // Dégradé de 360 couleurs entre la couleur de dessin et le blanc | ||||
| $vColor = getGDcolorGradientArray($vImage, 360, $couleurRGB, $fondRGB, $alpha); | |||||
| $vColor = getGDcolorGradientArray($vImage, 360, $vBgRGB, $vFgRGB, $alpha); | |||||
| // Le rayon du cercle dépend du montant de la transaction | // Le rayon du cercle dépend du montant de la transaction | ||||
| //$r0 = $width / 3; | //$r0 = $width / 3; | ||||
| @ -97,7 +84,7 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| // Un coef aléatoire | // Un coef aléatoire | ||||
| $coef = 0.1; | $coef = 0.1; | ||||
| $c = rand(0,10); | |||||
| $c = $transaction['value']%10; | |||||
| if ($c > 5) $coef = 0.3; | if ($c > 5) $coef = 0.3; | ||||
| if ($c > 7) $coef = 0.8; | if ($c > 7) $coef = 0.8; | ||||
| if ($c > 9) $coef = 1.2; | if ($c > 9) $coef = 1.2; | ||||
| @ -53,7 +53,7 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| //if (($x2 - $x1) < ($width*0.015)) break; | //if (($x2 - $x1) < ($width*0.015)) break; | ||||
| //if (($y2 - $y1) < ($height*0.015)) break; | //if (($y2 - $y1) < ($height*0.015)) break; | ||||
| $factor=rand(0,100); | |||||
| $factor=$the_block->nonce % 100; | |||||
| // Je triche: les petits rectangle sont blancs | // Je triche: les petits rectangle sont blancs | ||||
| if (($x2 - $x1) < 6) $factor=90; | if (($x2 - $x1) < 6) $factor=90; | ||||
| if (($y2 - $y1) < 6) $factor=90; | if (($y2 - $y1) < 6) $factor=90; | ||||
| @ -28,28 +28,15 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB']; | if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB']; | ||||
| if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | ||||
| // Une chance sur deux d'inverser entre fg et bg | |||||
| if (rand(0,100) < 50) { | |||||
| $fond = $vBgColor; | |||||
| $couleur = $vFgColor; | |||||
| $fondRGB = $vBgRGB; | |||||
| $couleurRGB = $vFgRGB; | |||||
| } else { | |||||
| $fond = $vFgColor; | |||||
| $couleur = $vBgColor; | |||||
| $fondRGB = $vFgRGB; | |||||
| $couleurRGB = $vBgRGB; | |||||
| } | |||||
| // Remplir le fond | // Remplir le fond | ||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond); | |||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $vFgColor); | |||||
| // Dégradé de 256 couleurs entre la couleur de fond et la couleur de dessin | // Dégradé de 256 couleurs entre la couleur de fond et la couleur de dessin | ||||
| $nb_colors = 256; | $nb_colors = 256; | ||||
| $vColor = array(); | $vColor = array(); | ||||
| $hex_val = array( | $hex_val = array( | ||||
| ColorGradient::rgb2hex($couleurRGB), | |||||
| ColorGradient::rgb2hex($fondRGB) | |||||
| ColorGradient::rgb2hex($vBgRGB), | |||||
| ColorGradient::rgb2hex($vFgRGB) | |||||
| ); | ); | ||||
| $gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors); | $gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors); | ||||
| for($i=0;$i<$nb_colors;$i++) | for($i=0;$i<$nb_colors;$i++) | ||||
| @ -33,30 +33,17 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| if (isset($parametres['iterations'])) $local_iterations = $parametres['iterations']; | if (isset($parametres['iterations'])) $local_iterations = $parametres['iterations']; | ||||
| $facteur_max = 2.5 * ($height / GRAPH_HEIGHT); | $facteur_max = 2.5 * ($height / GRAPH_HEIGHT); | ||||
| // Une chance sur deux d'inverser entre fg et bg | |||||
| if (rand(0,100) < 50) { | |||||
| $fond = $vBgColor; | |||||
| $couleur = $vFgColor; | |||||
| $fondRGB = $vBgRGB; | |||||
| $couleurRGB = $vFgRGB; | |||||
| } else { | |||||
| $fond = $vFgColor; | |||||
| $couleur = $vBgColor; | |||||
| $fondRGB = $vFgRGB; | |||||
| $couleurRGB = $vBgRGB; | |||||
| } | |||||
| // Remplir le fond | // Remplir le fond | ||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond); | |||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $vFgColor); | |||||
| // Dégradé de 256 couleurs entre la couleur de fond et la couleur de dessin | // Dégradé de 256 couleurs entre la couleur de fond et la couleur de dessin | ||||
| $alpha = 100; | $alpha = 100; | ||||
| $nb_colors = 256; | $nb_colors = 256; | ||||
| $vColor = array(); | $vColor = array(); | ||||
| $hex_val = array( | $hex_val = array( | ||||
| ColorGradient::rgb2hex($couleurRGB), | |||||
| ColorGradient::rgb2hex($fondRGB) | |||||
| ColorGradient::rgb2hex($vBgRGB), | |||||
| ColorGradient::rgb2hex($vFgRGB) | |||||
| ); | ); | ||||
| $gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors); | $gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors); | ||||
| for($i=0;$i<$nb_colors;$i++) | for($i=0;$i<$nb_colors;$i++) | ||||
| @ -148,7 +135,7 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| if ($valeur != 0) | if ($valeur != 0) | ||||
| { | { | ||||
| $decal = 15.0 * ($i / TX_HASH_LEN); | $decal = 15.0 * ($i / TX_HASH_LEN); | ||||
| $valeur += rand(0, floor($decal)); | |||||
| $valeur += floor($decal); | |||||
| $valeur /= 2; | $valeur /= 2; | ||||
| $valeur -= 8; | $valeur -= 8; | ||||
| $y0 = $h0 + ($valeur * $facteur); | $y0 = $h0 + ($valeur * $facteur); | ||||
| @ -99,11 +99,11 @@ $parametres['font_RGB'] = $paramHeader[4]; | |||||
| $parametres['background_RGB'] = $paramHeader[5]; | $parametres['background_RGB'] = $paramHeader[5]; | ||||
| // Une chance sur deux d'inverser entre fg et bg | // Une chance sur deux d'inverser entre fg et bg | ||||
| if (rand(0,100) < 50) { | |||||
| if (($the_block->nonce%2)==1) { | |||||
| $parametres['background_color'] = $paramHeader[2]; | $parametres['background_color'] = $paramHeader[2]; | ||||
| $parametres['background_RGB'] = $paramHeader[4]; | |||||
| $parametres['font_color'] = $paramHeader[1]; | |||||
| $parametres['font_RGB'] = $paramHeader[5]; | |||||
| $parametres['background_RGB'] = $paramHeader[4]; | |||||
| $parametres['font_color'] = $paramHeader[1]; | |||||
| $parametres['font_RGB'] = $paramHeader[5]; | |||||
| } | } | ||||
| DrawBlock($the_block, $img, $parametres); | DrawBlock($the_block, $img, $parametres); | ||||
| @ -29,7 +29,7 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | ||||
| // Forcer les couleurs | // Forcer les couleurs | ||||
| $hasard = rand(0,10); | |||||
| $hasard = $the_block->nonce % 10; | |||||
| $couleur=3;$val=0; | $couleur=3;$val=0; | ||||
| if ($hasard > $val++) $couleur = 5; | if ($hasard > $val++) $couleur = 5; | ||||
| if ($hasard > $val++) $couleur = 6; | if ($hasard > $val++) $couleur = 6; | ||||
| @ -34,23 +34,9 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| $facteur_max = 2.5 * ($height / GRAPH_HEIGHT); | $facteur_max = 2.5 * ($height / GRAPH_HEIGHT); | ||||
| // Une chance sur deux d'inverser entre fg et bg | |||||
| if (rand(0,100) < 50) { | |||||
| $fond = $vBgColor; | |||||
| $couleur = $vFgColor; | |||||
| $fondRGB = $vBgRGB; | |||||
| $couleurRGB = $vFgRGB; | |||||
| } else { | |||||
| $fond = $vFgColor; | |||||
| $couleur = $vBgColor; | |||||
| $fondRGB = $vFgRGB; | |||||
| $couleurRGB = $vBgRGB; | |||||
| } | |||||
| $fondRGB=[0,0,0]; | $fondRGB=[0,0,0]; | ||||
| $fond=imagecolorallocate($vImage,$fondRGB[0],$fondRGB[1],$fondRGB[2]); | $fond=imagecolorallocate($vImage,$fondRGB[0],$fondRGB[1],$fondRGB[2]); | ||||
| $couleurRGB=[240,147,43]; | $couleurRGB=[240,147,43]; | ||||
| $couleur=imagecolorallocate($vImage,$couleurRGB[0],$couleurRGB[1],$couleurRGB[2]); | |||||
| // Remplir le fond | // Remplir le fond | ||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond); | imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond); | ||||
| @ -168,7 +154,7 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| if ($valeur != 0) | if ($valeur != 0) | ||||
| { | { | ||||
| $decal = 15.0 * ($i / TX_HASH_LEN); | $decal = 15.0 * ($i / TX_HASH_LEN); | ||||
| $valeur += rand(0, floor($decal)); | |||||
| $valeur += floor($decal); | |||||
| $valeur /= 2; | $valeur /= 2; | ||||
| $valeur -= 8; | $valeur -= 8; | ||||
| $y0 = $h0 + ($valeur * $facteur); | $y0 = $h0 + ($valeur * $facteur); | ||||
| @ -28,28 +28,15 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB']; | if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB']; | ||||
| if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB']; | ||||
| // Une chance sur deux d'inverser entre fg et bg | |||||
| if (rand(0,100) < 50) { | |||||
| $fond = $vBgColor; | |||||
| $couleur = $vFgColor; | |||||
| $fondRGB = $vBgRGB; | |||||
| $couleurRGB = $vFgRGB; | |||||
| } else { | |||||
| $fond = $vFgColor; | |||||
| $couleur = $vBgColor; | |||||
| $fondRGB = $vFgRGB; | |||||
| $couleurRGB = $vBgRGB; | |||||
| } | |||||
| // Remplir le fond | // Remplir le fond | ||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond); | |||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $vFgColor); | |||||
| // Dégradé de 256 couleurs entre la couleur de fond et la couleur de dessin | // Dégradé de 256 couleurs entre la couleur de fond et la couleur de dessin | ||||
| $nb_colors = 256; | $nb_colors = 256; | ||||
| $vColor = array(); | $vColor = array(); | ||||
| $hex_val = array( | $hex_val = array( | ||||
| ColorGradient::rgb2hex($couleurRGB), | |||||
| ColorGradient::rgb2hex($fondRGB) | |||||
| ColorGradient::rgb2hex($vBgRGB), | |||||
| ColorGradient::rgb2hex($vFgRGB) | |||||
| ); | ); | ||||
| $gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors); | $gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors); | ||||
| for($i=0;$i<$nb_colors;$i++) | for($i=0;$i<$nb_colors;$i++) | ||||
| @ -34,29 +34,16 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| $facteur_max = 2.5 * ($height / GRAPH_HEIGHT); | $facteur_max = 2.5 * ($height / GRAPH_HEIGHT); | ||||
| // Une chance sur deux d'inverser entre fg et bg | |||||
| if (rand(0,100) < 50) { | |||||
| $fond = $vBgColor; | |||||
| $couleur = $vFgColor; | |||||
| $fondRGB = $vBgRGB; | |||||
| $couleurRGB = $vFgRGB; | |||||
| } else { | |||||
| $fond = $vFgColor; | |||||
| $couleur = $vBgColor; | |||||
| $fondRGB = $vFgRGB; | |||||
| $couleurRGB = $vBgRGB; | |||||
| } | |||||
| // Remplir le fond | // Remplir le fond | ||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond); | |||||
| imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $vFgColor); | |||||
| // Dégradé de 256 couleurs entre la couleur de fond et la couleur de dessin | // Dégradé de 256 couleurs entre la couleur de fond et la couleur de dessin | ||||
| $alpha = 100; | $alpha = 100; | ||||
| $nb_colors = 256; | $nb_colors = 256; | ||||
| $vColor = array(); | $vColor = array(); | ||||
| $hex_val = array( | $hex_val = array( | ||||
| ColorGradient::rgb2hex($couleurRGB), | |||||
| ColorGradient::rgb2hex($fondRGB) | |||||
| ColorGradient::rgb2hex($vBgRGB), | |||||
| ColorGradient::rgb2hex($vFgRGB) | |||||
| ); | ); | ||||
| $gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors); | $gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors); | ||||
| for($i=0;$i<$nb_colors;$i++) | for($i=0;$i<$nb_colors;$i++) | ||||
| @ -148,7 +135,7 @@ function DrawBlock($the_block, $vImage, $parametres) | |||||
| if ($valeur != 0) | if ($valeur != 0) | ||||
| { | { | ||||
| $decal = 15.0 * ($i / TX_HASH_LEN); | $decal = 15.0 * ($i / TX_HASH_LEN); | ||||
| $valeur += rand(0, floor($decal)); | |||||
| $valeur += floor($decal); | |||||
| $valeur /= 2; | $valeur /= 2; | ||||
| $valeur -= 8; | $valeur -= 8; | ||||
| $y0 = $h0 + ($valeur * $facteur); | $y0 = $h0 + ($valeur * $facteur); | ||||
| @ -91,15 +91,11 @@ while IFS='' read -r line || [[ -n "$line" ]]; do | |||||
| then | then | ||||
| php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2 | php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2 | ||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png | cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png | ||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png | |||||
| fi | fi | ||||
| done | done | ||||
| cd - >> /dev/null | cd - >> /dev/null | ||||
| if [ ! -f $DATA_PATH/hasard/$BLOCK.png ] | |||||
| then | |||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png | |||||
| fi | |||||
| if [ ! -f $DATA_PATH/nonce/$BLOCK.png ] | if [ ! -f $DATA_PATH/nonce/$BLOCK.png ] | ||||
| then | then | ||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png | cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png | ||||
| @ -0,0 +1,121 @@ | |||||
| #!/bin/bash | |||||
| lescript=`basename $0 .sh` | |||||
| flag=$TMP_PATH/bot_$lescript.flag | |||||
| # | |||||
| # TOOLS | |||||
| # | |||||
| function debug | |||||
| { | |||||
| if [ -f $FLAG_PATH/debug ] | |||||
| then | |||||
| echo $1 | |||||
| fi | |||||
| } | |||||
| function sortie | |||||
| { | |||||
| exit $1 | |||||
| } | |||||
| function succes | |||||
| { | |||||
| debug "SUCCES" | |||||
| sortie 0 | |||||
| } | |||||
| function echec | |||||
| { | |||||
| debug "ECHEC" | |||||
| exit 1 | |||||
| } | |||||
| # | |||||
| # PARAMETRES PAR FICHIER FLAGS | |||||
| # | |||||
| if [ -f $FLAG_PATH/no_blocks ] | |||||
| then | |||||
| debug "No blocks" | |||||
| echec | |||||
| fi | |||||
| while IFS='' read -r line || [[ -n "$line" ]]; do | |||||
| NAME=`echo $line | awk '{print $1}'` | |||||
| BLOCK=`echo $line | awk '{print $2}'` | |||||
| HEIGHT=`echo $line | awk '{print $3}'` | |||||
| NBTX=`echo $line | awk '{print $4}'` | |||||
| # | |||||
| # TEST DU FLAG | |||||
| # | |||||
| flag=$FLAG_PATH/bot_${lescript}_${BLOCK}.flag | |||||
| if [ -f $flag ] | |||||
| then | |||||
| debug "${lescript}_${BLOCK} already done" | |||||
| continue | |||||
| fi | |||||
| touch $flag | |||||
| if [ ! -f $DATA_PATH/nonce/$BLOCK.png ] | |||||
| then | |||||
| # | |||||
| # Si c'est la première fois que l'on dessine le block | |||||
| # On choisit la méthode qui découle du nonce | |||||
| # | |||||
| cd $APPS_PATH/nonce | |||||
| nbmethodes=`cat $DATA_PATH/nonce_methods_list.txt | wc -l` | |||||
| lenonce=`php robot.php $BLOCK` | |||||
| lamethode=$((lenonce % nbmethodes)) | |||||
| if [ $lamethode -eq 0 ] | |||||
| then | |||||
| lamethode=$nbmethodes | |||||
| fi | |||||
| LISTE_METHODE=`cat $DATA_PATH/nonce_methods_list.txt | head -n $lamethode | tail -1` | |||||
| else | |||||
| # | |||||
| # CHOISIR UNE METHODE2 AU HASARD | |||||
| # | |||||
| LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf` | |||||
| if [ $NBTX -lt 10 ] | |||||
| then | |||||
| LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | grep -v treemap | grep -v mondrian | shuf` | |||||
| fi | |||||
| fi | |||||
| cd $APPS_PATH/methode2 | |||||
| for METHODE in $LISTE_METHODE | |||||
| do | |||||
| if [ ! -d $DATA_PATH/$METHODE ] | |||||
| then | |||||
| mkdir -p $DATA_PATH/$METHODE | |||||
| fi | |||||
| echo $BLOCK $NAME $METHODE | |||||
| if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ] | |||||
| then | |||||
| php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2 | |||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png | |||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png | |||||
| fi | |||||
| done | |||||
| cd - >> /dev/null | |||||
| if [ ! -f $DATA_PATH/nonce/$BLOCK.png ] | |||||
| then | |||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png | |||||
| fi | |||||
| rm -f $flag | |||||
| done < $DATA_PATH/block_list.txt | |||||
| # | |||||
| # List of finished blocks | |||||
| # | |||||
| rm -f $DATA_PATH/finished_block_list.txt | |||||
| grep -v CACHE $DATA_PATH/block_list.txt >> $DATA_PATH/finished_block_list.txt | |||||
| # | |||||
| # SORTIE AVEC SUCCES | |||||
| # | |||||
| succes | |||||