enlever le hasard

This commit is contained in:
2022-08-21 09:30:06 +02:00
parent 6d161b3804
commit 0bf16e3ab5
17 changed files with 161 additions and 174 deletions
+4 -17
View File
@@ -29,35 +29,22 @@ function DrawBlock($the_block, $vImage, $parametres)
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_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
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
$vColor = getGDcolorGradientArray($vImage, 360, $couleurRGB, $fondRGB, $alpha);
$nbColor = 360;
$vColor = getGDcolorGradientArray($vImage, $nbColor, $vBgRGB, $vFgRGB, $alpha);
// Récup des données
$data = blockchain::getTransactionData($the_block, $type);
$n_data = count($data);
$xc = $x + ($width / 2);
$yc = $y + ($height / 2);
foreach($data as $transaction)
{
for($i=0;$i<360;$i++)
for($i=0;$i<$nbColor;$i++)
{
$valeur = hexdec($transaction['hash'][$i%TX_HASH_LEN]);
if ($valeur != 0) $valeur += $valeur - 8;
+4 -16
View File
@@ -29,24 +29,11 @@ function DrawBlock($the_block, $vImage, $parametres)
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_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
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
$vColor = getGDcolorGradientArray($vImage, 360, $couleurRGB, $fondRGB, $alpha);
$vColor = getGDcolorGradientArray($vImage, 360, $vBgRGB, $vBgRGB, $alpha);
// Récup des données
$data = blockchain::getTransactionData($the_block, $type);
@@ -63,7 +50,8 @@ function DrawBlock($the_block, $vImage, $parametres)
for($i=0;$i<TX_HASH_LEN;$i++)
{
$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))));
$yi = floor($yc + $r*sin(deg2rad($i*(360/TX_HASH_LEN))));
+3 -16
View File
@@ -28,21 +28,8 @@ function DrawBlock($the_block, $vImage, $parametres)
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_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
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
$data = blockchain::getTransactionData($the_block, $type);
@@ -56,7 +43,7 @@ function DrawBlock($the_block, $vImage, $parametres)
if ($nb < 5) $alpha = 0;
// 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
$oCurve = new CubicSplines();
@@ -71,7 +58,7 @@ function DrawBlock($the_block, $vImage, $parametres)
{
// Un coef aléatoire
$coef = 0.1;
$c = rand(0,10);
$c = $transaction['value']%10;
if ($c > 5) $coef = 0.3;
if ($c > 7) $coef = 0.8;
if ($c > 9) $coef = 1.2;
+2 -15
View File
@@ -29,24 +29,11 @@ function DrawBlock($the_block, $vImage, $parametres)
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_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
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
$vColor = getGDcolorGradientArray($vImage, 360, $couleurRGB, $fondRGB, $alpha);
$vColor = getGDcolorGradientArray($vImage, 360, $vBgRGB, $vFgRGB, $alpha);
// Récup des données
$data = blockchain::getTransactionData($the_block, $type);
+3 -16
View File
@@ -28,21 +28,8 @@ function DrawBlock($the_block, $vImage, $parametres)
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_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
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
$data = blockchain::getTransactionData($the_block, $type);
@@ -66,7 +53,7 @@ function DrawBlock($the_block, $vImage, $parametres)
if ($nb < 5) $alpha = 0;
// 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
//$r0 = $width / 3;
@@ -97,7 +84,7 @@ function DrawBlock($the_block, $vImage, $parametres)
// Un coef aléatoire
$coef = 0.1;
$c = rand(0,10);
$c = $transaction['value']%10;
if ($c > 5) $coef = 0.3;
if ($c > 7) $coef = 0.8;
if ($c > 9) $coef = 1.2;
+1 -1
View File
@@ -53,7 +53,7 @@ function DrawBlock($the_block, $vImage, $parametres)
//if (($x2 - $x1) < ($width*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
if (($x2 - $x1) < 6) $factor=90;
if (($y2 - $y1) < 6) $factor=90;
+3 -16
View File
@@ -28,28 +28,15 @@ function DrawBlock($the_block, $vImage, $parametres)
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_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
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
$nb_colors = 256;
$vColor = 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);
for($i=0;$i<$nb_colors;$i++)
+5 -18
View File
@@ -33,30 +33,17 @@ function DrawBlock($the_block, $vImage, $parametres)
if (isset($parametres['iterations'])) $local_iterations = $parametres['iterations'];
$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
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
$alpha = 100;
$nb_colors = 256;
$vColor = 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);
for($i=0;$i<$nb_colors;$i++)
@@ -148,7 +135,7 @@ function DrawBlock($the_block, $vImage, $parametres)
if ($valeur != 0)
{
$decal = 15.0 * ($i / TX_HASH_LEN);
$valeur += rand(0, floor($decal));
$valeur += floor($decal);
$valeur /= 2;
$valeur -= 8;
$y0 = $h0 + ($valeur * $facteur);
+4 -4
View File
@@ -99,11 +99,11 @@ $parametres['font_RGB'] = $paramHeader[4];
$parametres['background_RGB'] = $paramHeader[5];
// 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_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);
+1 -1
View File
@@ -29,7 +29,7 @@ function DrawBlock($the_block, $vImage, $parametres)
if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB'];
// Forcer les couleurs
$hasard = rand(0,10);
$hasard = $the_block->nonce % 10;
$couleur=3;$val=0;
if ($hasard > $val++) $couleur = 5;
if ($hasard > $val++) $couleur = 6;
+1 -15
View File
@@ -34,23 +34,9 @@ function DrawBlock($the_block, $vImage, $parametres)
$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];
$fond=imagecolorallocate($vImage,$fondRGB[0],$fondRGB[1],$fondRGB[2]);
$couleurRGB=[240,147,43];
$couleur=imagecolorallocate($vImage,$couleurRGB[0],$couleurRGB[1],$couleurRGB[2]);
// Remplir le 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)
{
$decal = 15.0 * ($i / TX_HASH_LEN);
$valeur += rand(0, floor($decal));
$valeur += floor($decal);
$valeur /= 2;
$valeur -= 8;
$y0 = $h0 + ($valeur * $facteur);
+3 -16
View File
@@ -28,28 +28,15 @@ function DrawBlock($the_block, $vImage, $parametres)
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_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
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
$nb_colors = 256;
$vColor = 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);
for($i=0;$i<$nb_colors;$i++)
+4 -17
View File
@@ -34,29 +34,16 @@ function DrawBlock($the_block, $vImage, $parametres)
$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
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
$alpha = 100;
$nb_colors = 256;
$vColor = 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);
for($i=0;$i<$nb_colors;$i++)
@@ -148,7 +135,7 @@ function DrawBlock($the_block, $vImage, $parametres)
if ($valeur != 0)
{
$decal = 15.0 * ($i / TX_HASH_LEN);
$valeur += rand(0, floor($decal));
$valeur += floor($decal);
$valeur /= 2;
$valeur -= 8;
$y0 = $h0 + ($valeur * $facteur);