This commit is contained in:
2018-10-31 10:06:43 +01:00
parent e121c6f6dd
commit b3ad46d98a
39 changed files with 1757 additions and 1116 deletions

86
methode2/line/draw.php Normal file
View File

@@ -0,0 +1,86 @@
<?php
function DrawBlock($the_block, $vImage, $parametres)
{
// valeurs par défaut
$type = 1;
// Ces variables vont permettre de caler les lignes
// dans la zone de dessin en se laissant des marges
// en haut et en bas
$somme = 0;
$min =-1;
$max = 0;
$marge_x = 10;
$marge_y = 10;
// Détermine si on dessine les tx, les fees ou la récompense
if (isset($parametres['type'])) $type = $parametres['type'];
// Paramètres de dessin
if (isset($parametres['x'])) $x = $parametres['x'];
if (isset($parametres['y'])) $y = $parametres['y'];
if (isset($parametres['width'])) $width = $parametres['width'];
if (isset($parametres['height'])) $height = $parametres['height'];
if (isset($parametres['font_color'])) $vFgColor = $parametres['font_color'];
if (isset($parametres['background_color'])) $vBgColor = $parametres['background_color'];
// Remplir le fond
imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-($marge_x/2), $y+$height-($marge_y/2), $vBgColor);
// Récup des données
$data = blockchain::getTransactionData($the_block, $type);
$n_data = count($data);
// Calcul des min max
foreach($data as $v)
{
if ($v['value'] > $max) $max = $v['value'];
if (($v['value'] < $min)||($min == -1)) $min = $v['value'];
$somme += $v['value'];
}
if ($min == $max) $max = $min + 1;
if ($somme == 0) return;
$coef = ($height - (2*$marge_y)) / $somme;
$dx = $width - (2*$marge_x);
$limite_x = $x + $dx;
$h0 = 0;
$hauteur = $y + $marge_y;
$special_draw = (count($data) == 1);
foreach($data as $transaction)
{
//
// La nouvelle hauteur : cumule des montants de transaction
//
$hauteur += $coef * $transaction['value'];
//
// Cas des blocks qui n'ont qu'une seule transaction
// On se cale au milieu
//
if ($special_draw) $hauteur = $y + ($height / 2);
//
// Ne pas tracer 2 lignes à la même hauteur
// => c'est possible du fait de l'arrondi
// si la transaction a un montant faible
//
if ((floor($hauteur)-$h0)<2) continue;
$h0 = floor($hauteur);
//
// On recommence en début de ligne
//
$x0 = $x + $marge_x;
//
// La première partie est une ligne droite
//
imageline($vImage, $x0, $h0, $x0+$dx, $h0, $vFgColor);
}
}
?>

View File

@@ -0,0 +1,106 @@
<?php
function DrawBlock($the_block, $vImage, $parametres)
{
// valeurs par défaut
$type = 1;
// Ces variables vont permettre de caler les lignes
// dans la zone de dessin en se laissant des marges
// en haut et en bas
$somme = 0;
$min =-1;
$max = 0;
$marge_x = 10;
$marge_y = 10;
// Détermine si on dessine les tx, les fees ou la récompense
if (isset($parametres['type'])) $type = $parametres['type'];
// Paramètres de dessin
if (isset($parametres['x'])) $x = $parametres['x'];
if (isset($parametres['y'])) $y = $parametres['y'];
if (isset($parametres['width'])) $width = $parametres['width'];
if (isset($parametres['height'])) $height = $parametres['height'];
if (isset($parametres['font_color'])) $vFgColor = $parametres['font_color'];
if (isset($parametres['background_color'])) $vBgColor = $parametres['background_color'];
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB'];
if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB'];
// Remplir le fond
imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-($marge_x/2), $y+$height-($marge_y/2), $vBgColor);
// 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($vFgRGB),
ColorGradient::rgb2hex($vBgRGB)
);
$gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors);
for($i=0;$i<$nb_colors;$i++)
{
$rgbval = ColorGradient::hex2rgb($gradient[$i]);
$vColor[$i] = new ColorGradient();
$vColor[$i]->pct = ($i*1.0) / $nb_colors;
$vColor[$i]->color = imagecolorallocate($vImage, $rgbval[0], $rgbval[1], $rgbval[2]);
}
// Récup des données
$data = blockchain::getTransactionData($the_block, $type);
$n_data = count($data);
// Calcul des min max
foreach($data as $v)
{
if ($v['value'] > $max) $max = $v['value'];
if (($v['value'] < $min)||($min == -1)) $min = $v['value'];
$somme += $v['value'];
}
if ($min == $max) $max = $min + 1;
if ($somme == 0) return;
$coef = ($height - (2*$marge_y)) / $somme;
$limite_x = $x + ($width - (2*$marge_x));
$dx = round(($width - (2*$marge_x)) / (TX_HASH_LEN));
$h0 = 0;
$hauteur = $y + $marge_y;
$special_draw = (count($data) == 1);
foreach($data as $transaction)
{
//
// La nouvelle hauteur : cumule des montants de transaction
//
$hauteur += $coef * $transaction['value'];
//
// Cas des blocks qui n'ont qu'une seule transaction
// On se cale au milieu
//
if ($special_draw) $hauteur = $y + ($height / 2);
//
// Ne pas tracer 2 lignes à la même hauteur
// => c'est possible du fait de l'arrondi
// si la transaction a un montant faible
//
if ((floor($hauteur)-$h0)<2) continue;
$h0 = floor($hauteur);
//
// On trace
//
$x0 = $x + $marge_x;
while($x0 < $limite_x)
{
$pct = (($x0 - $x)*1.0) / ($limite_x - $x);
$index = floor($pct*$nb_colors);
imageline($vImage, $x0, $h0, $x0+$dx, $h0, $vColor[$index]->color);
$x0 += $dx;
}
}
}
?>

View File

@@ -0,0 +1,119 @@
<?php
function DrawBlock($the_block, $vImage, $parametres)
{
// valeurs par défaut
$type = 1;
$facteur_max = 2.5;
// Ces variables vont permettre de caler les lignes
// dans la zone de dessin en se laissant des marges
// en haut et en bas
$somme = 0;
$min =-1;
$max = 0;
$marge_x = 10;
$marge_y = 10;
// Détermine si on dessine les tx, les fees ou la récompense
if (isset($parametres['type'])) $type = $parametres['type'];
// Paramètres de dessin
if (isset($parametres['x'])) $x = $parametres['x'];
if (isset($parametres['y'])) $y = $parametres['y'];
if (isset($parametres['width'])) $width = $parametres['width'];
if (isset($parametres['height'])) $height = $parametres['height'];
if (isset($parametres['font_color'])) $vFgColor = $parametres['font_color'];
if (isset($parametres['background_color'])) $vBgColor = $parametres['background_color'];
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB'];
if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB'];
// Remplir le fond
imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-($marge_x/2), $y+$height-($marge_y/2), $vBgColor);
// 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($vFgRGB),
ColorGradient::rgb2hex($vBgRGB)
);
$gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors);
for($i=0;$i<$nb_colors;$i++)
{
$rgbval = ColorGradient::hex2rgb($gradient[$i]);
$vColor[$i] = new ColorGradient();
$vColor[$i]->pct = ($i*1.0) / $nb_colors;
$vColor[$i]->color = imagecolorallocate($vImage, $rgbval[0], $rgbval[1], $rgbval[2]);
}
// Récup des données
$data = blockchain::getTransactionData($the_block, $type);
$n_data = count($data);
// Calcul des min max
foreach($data as $v)
{
if ($v['value'] > $max) $max = $v['value'];
if (($v['value'] < $min)||($min == -1)) $min = $v['value'];
$somme += $v['value'];
}
if ($min == $max) $max = $min + 1;
if ($somme == 0) return;
$coef = ($height - (2*$marge_y)) / $somme;
$limite_x = $x + ($width - (2*$marge_x));
$dx = round(($width - (2*$marge_x)) / (TX_HASH_LEN));
$h0 = 0;
$hauteur = $y + $marge_y;
$special_draw = (count($data) == 1);
foreach($data as $transaction)
{
//
// La nouvelle hauteur : cumule des montants de transaction
//
$hauteur += $coef * $transaction['value'];
//
// Cas des blocks qui n'ont qu'une seule transaction
// On se cale au milieu
//
if ($special_draw) $hauteur = $y + ($height / 2);
//
// Ne pas tracer 2 lignes à la même hauteur
// => c'est possible du fait de l'arrondi
// si la transaction a un montant faible
//
if ((floor($hauteur)-$h0)<2) continue;
$h0 = floor($hauteur);
$facteur = 0.1;
//
// On trace
//
$x0 = $x + $marge_x;
for ($i = 0; $i < TX_HASH_LEN; $i++)
{
$y0 = $h0;
$valeur = hexdec($the_block->hash[$i]);
if ($valeur != 0) $y0 += floor(($valeur - 8) * $facteur);
if ($y0 < $y+$marge_y) $y0 = $y+$marge_y;
if ($y0 > ($y+$height-$marge_y)) $y0 = $y+$height-$marge_y;
$pct = (($x0 - $x)*1.0) / ($limite_x - $x);
$index = floor($pct*$nb_colors);
imageline($vImage, $x0, $y0, $x0+$dx, $y0, $vColor[$index]->color);
$x0 += $dx;
if ($y0 == $h0) continue;
$facteur = 0.1 + (($facteur_max*$i) / TX_HASH_LEN);
if ($facteur > $facteur_max) $facteur = $facteur_max;
}
}
}
?>

View File

@@ -0,0 +1,119 @@
<?php
function DrawBlock($the_block, $vImage, $parametres)
{
// valeurs par défaut
$type = 1;
$facteur_max = 2.5;
// Ces variables vont permettre de caler les lignes
// dans la zone de dessin en se laissant des marges
// en haut et en bas
$somme = 0;
$min =-1;
$max = 0;
$marge_x = 10;
$marge_y = 10;
// Détermine si on dessine les tx, les fees ou la récompense
if (isset($parametres['type'])) $type = $parametres['type'];
// Paramètres de dessin
if (isset($parametres['x'])) $x = $parametres['x'];
if (isset($parametres['y'])) $y = $parametres['y'];
if (isset($parametres['width'])) $width = $parametres['width'];
if (isset($parametres['height'])) $height = $parametres['height'];
if (isset($parametres['font_color'])) $vFgColor = $parametres['font_color'];
if (isset($parametres['background_color'])) $vBgColor = $parametres['background_color'];
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB'];
if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB'];
// Remplir le fond
imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-($marge_x/2), $y+$height-($marge_y/2), $vBgColor);
// 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($vFgRGB),
ColorGradient::rgb2hex($vBgRGB)
);
$gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors);
for($i=0;$i<$nb_colors;$i++)
{
$rgbval = ColorGradient::hex2rgb($gradient[$i]);
$vColor[$i] = new ColorGradient();
$vColor[$i]->pct = ($i*1.0) / $nb_colors;
$vColor[$i]->color = imagecolorallocate($vImage, $rgbval[0], $rgbval[1], $rgbval[2]);
}
// Récup des données
$data = blockchain::getTransactionData($the_block, $type);
$n_data = count($data);
// Calcul des min max
foreach($data as $v)
{
if ($v['value'] > $max) $max = $v['value'];
if (($v['value'] < $min)||($min == -1)) $min = $v['value'];
$somme += $v['value'];
}
if ($min == $max) $max = $min + 1;
if ($somme == 0) return;
$coef = ($height - (2*$marge_y)) / $somme;
$limite_x = $x + ($width - (2*$marge_x));
$dx = round(($width - (2*$marge_x)) / (TX_HASH_LEN));
$h0 = 0;
$hauteur = $y + $marge_y;
$special_draw = (count($data) == 1);
foreach($data as $transaction)
{
//
// La nouvelle hauteur : cumule des montants de transaction
//
$hauteur += $coef * $transaction['value'];
//
// Cas des blocks qui n'ont qu'une seule transaction
// On se cale au milieu
//
if ($special_draw) $hauteur = $y + ($height / 2);
//
// Ne pas tracer 2 lignes à la même hauteur
// => c'est possible du fait de l'arrondi
// si la transaction a un montant faible
//
if ((floor($hauteur)-$h0)<2) continue;
$h0 = floor($hauteur);
$facteur = 0.1;
//
// On trace
//
$x0 = $x + $marge_x;
for ($i = 0; $i < TX_HASH_LEN; $i++)
{
$y0 = $h0;
$valeur = hexdec($transaction['hash'][$i]);
if ($valeur != 0) $y0 += floor(($valeur - 8) * $facteur);
if ($y0 < $y+$marge_y) $y0 = $y+$marge_y;
if ($y0 > ($y+$height-$marge_y)) $y0 = $y+$height-$marge_y;
$pct = (($x0 - $x)*1.0) / ($limite_x - $x);
$index = floor($pct*$nb_colors);
imageline($vImage, $x0, $y0, $x0+$dx, $y0, $vColor[$index]->color);
$x0 += $dx;
if ($y0 == $h0) continue;
$facteur = 0.1 + (($facteur_max*$i) / TX_HASH_LEN);
if ($facteur > $facteur_max) $facteur = $facteur_max;
}
}
}
?>

View File

@@ -0,0 +1,89 @@
<?php
use codeagent\treemap\Treemap;
use codeagent\treemap\presenter\ImagePresenter;
use codeagent\treemap\presenter\NodeInfo;
function DrawBlock($the_block, $vImage, $parametres)
{
$type = 1;
if (isset($parametres['x'])) $x = $parametres['x']+2;
if (isset($parametres['y'])) $y = $parametres['y']+2;
if (isset($parametres['width'])) $width = $parametres['width']-4;
if (isset($parametres['height'])) $height = $parametres['height']-4;
if (isset($parametres['methode'])) $mode = $parametres['methode'];
if (isset($parametres['type'])) $type = $parametres['type'];
if (isset($parametres['font_color'])) $vBgColor = $parametres['font_color'];
if (isset($parametres['background_color'])) $vFgColor = $parametres['background_color'];
imagefilledrectangle($vImage, $x, $y, $x+$width, $y+$height, $vFgColor);
$couleurs = array();
$couleurs[0] = imagecolorallocate($vImage, 255, 255, 255);
$couleurs[1] = imagecolorallocate($vImage, 255, 0, 0);
$couleurs[2] = imagecolorallocate($vImage, 0, 0, 255);
$couleurs[3] = imagecolorallocate($vImage, 255, 255, 0);
$full_area = $width * $height;
if ($full_area == 0) $full_area = 1;
$data = blockchain::getTransactionData($the_block, $type);
$treemap = new Treemap($data, $width, $height);
$map = $treemap->getMap();
$m = count($map);
$flag_contour = true;
for($mm = 0; $mm < $m; $mm++)
{
$tx = $map[$mm];
$factor = (($tx['_rectangle']->width * $tx['_rectangle']->height) / $full_area)*100.0;
$x1 = $x + $tx['_rectangle']->left;
$y1 = $y + $tx['_rectangle']->top;
$x2 = $x1 + $tx['_rectangle']->width;
$y2 = $y1 + $tx['_rectangle']->height;
if ($x1 > ($x+$width)) $x1 = ($x+$width);
if ($y1 > ($y+$height)) $y1 = ($y+$height);
if ($x2 > ($x+$width)) $x2 = ($x+$width);
if ($y2 > ($y+$height)) $y2 = ($y+$height);
//if (($x2 - $x1) < ($width*0.015)) break;
//if (($y2 - $y1) < ($height*0.015)) break;
$factor=rand(0,100);
// Je triche: les petits rectangle sont blancs
if (($x2 - $x1) < 6) $factor=90;
if (($y2 - $y1) < 6) $factor=90;
$couleur = 0;
if ($factor < 50) $couleur += 1;
if ($factor < 25) $couleur += 1;
if ($factor < 10) $couleur += 1;
// Pourtour noir
imagefilledrectangle($vImage, $x1, $y1, $x2, $y2, $vBgColor);
// Intérieur de couleur
$dx = 1 + floor(0.0025 * $width);
$dy = 1 + floor(0.0025 * $height);
// Je triche: les petits rectangle ont un tour de 1 pixel
if (($x2 - $x1) < 6) $dy=1;
if (($y2 - $y1) < 6) $dy=1;
$x1 = $x1 + $dx;$x2 = $x2 - $dx;
$y1 = $y1 + $dy;$y2 = $y2 - $dy;
if ($x1 > ($x+$width)) $x1 = ($x+$width);
if ($y1 > ($y+$height)) $y1 = ($y+$height);
if ($x2 > ($x+$width)) $x2 = ($x+$width);
if ($y2 > ($y+$height)) $y2 = ($y+$height);
imagefilledrectangle($vImage, $x1, $y1, $x2, $y2, $couleurs[$couleur]);
}
if ($mm < $m) imagerectangle($vImage, $x1, $y1, $x+$width, $y+$height, $vBgColor);
}
?>

156
methode2/peigne/draw.php Normal file
View File

@@ -0,0 +1,156 @@
<?php
function DrawBlock($the_block, $vImage, $parametres)
{
// valeurs par défaut
$type = 1;
// Ces variables vont permettre de caler les lignes
// dans la zone de dessin en se laissant des marges
// en haut et en bas
$somme = 0;
$min =-1;
$max = 0;
$marge_x = 10;
$marge_y = 10;
$facteur_max = 2.5;
// Détermine si on dessine les tx, les fees ou la récompense
if (isset($parametres['type'])) $type = $parametres['type'];
// Paramètres de dessin
if (isset($parametres['x'])) $x = $parametres['x'];
if (isset($parametres['y'])) $y = $parametres['y'];
if (isset($parametres['width'])) $width = $parametres['width'];
if (isset($parametres['height'])) $height = $parametres['height'];
if (isset($parametres['font_color'])) $vFgColor = $parametres['font_color'];
if (isset($parametres['background_color'])) $vBgColor = $parametres['background_color'];
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);
// 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)
);
$gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors);
for($i=0;$i<$nb_colors;$i++)
{
$rgbval = ColorGradient::hex2rgb($gradient[$i]);
$vColor[$i] = new ColorGradient();
$vColor[$i]->pct = ($i*1.0) / $nb_colors;
$vColor[$i]->color = imagecolorallocate($vImage, $rgbval[0], $rgbval[1], $rgbval[2]);
}
// Récup des données
$data = blockchain::getTransactionData($the_block, $type);
$n_data = count($data);
// Un calculateur de Spline
$oCurve = new CubicSplines();
// Calcul des min max
foreach($data as $v)
{
if ($v['value'] > $max) $max = $v['value'];
if (($v['value'] < $min)||($min == -1)) $min = $v['value'];
$somme += $v['value'];
}
if ($min == $max) $max = $min + 1;
if ($somme == 0) return;
// On se prend une plus grosse marge en hauteur
$coef = ($height - (4*$marge_y)) / $somme;
$limite_x = $x + ($width - (2*$marge_x));
$dx = round(($width - (2*$marge_x)) / (TX_HASH_LEN+10));
$h0 = 0;
$hauteur = $y + (2*$marge_y);
$special_draw = (count($data) == 1);
foreach($data as $transaction)
{
//
// La nouvelle hauteur : cumule des montants de transaction
//
$hauteur += $coef * $transaction['value'];
//
// Cas des blocks qui n'ont qu'une seule transaction
// On se cale au milieu
//
if ($special_draw) $hauteur = $y + ($height / 2);
//
// Ne pas tracer 2 lignes à la même hauteur
// => c'est possible du fait de l'arrondi
// si la transaction a un montant faible
//
if ((floor($hauteur)-$h0)<2) continue;
$h0 = floor($hauteur);
$x0 = $x + $marge_x;
//
// On découpe la ligne en fonction du nombre de DIGIT
// dans le hash des transactions
//
$facteur = 0.1;
$aCoords = array();
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
for ($i = 0; $i < TX_HASH_LEN; $i++)
{
$y0 = $h0;
$valeur = hexdec($the_block->hash[$i]);
if ($valeur != 0) $y0 += floor(($valeur - 8) * $facteur);
if ($y0 < $y+$marge_y) $y0 = $y+$marge_y;
if ($y0 > ($y+$height-$marge_y)) $y0 = $y+$height-$marge_y;
$x0 += $dx;
$aCoords[$x0] = $y0;
if ($y0 == $h0) continue;
$facteur = 0.1 + (($facteur_max*$i) / TX_HASH_LEN);
if ($facteur > $facteur_max) $facteur = $facteur_max;
}
if ($oCurve)
{
$oCurve->setInitCoords($aCoords);
$r = $oCurve->processCoords();
if ($r)
{
$curveGraph = new Plot($r);
$curveGraph->drawLine($vImage, $vColor, $x0, $limite_x);
}
}
}
}
?>

View File

@@ -0,0 +1,181 @@
<?php
function DrawBlock($the_block, $vImage, $parametres)
{
// valeurs par défaut
$type = 1;
// Ces variables vont permettre de caler les lignes
// dans la zone de dessin en se laissant des marges
// en haut et en bas
$somme = 0;
$min =-1;
$max = 0;
$marge_x = 10;
$marge_y = 10;
$facteur_max = 2.5;
$local_iterations = 100;
// Détermine si on dessine les tx, les fees ou la récompense
if (isset($parametres['type'])) $type = $parametres['type'];
// Paramètres de dessin
if (isset($parametres['x'])) $x = $parametres['x'];
if (isset($parametres['y'])) $y = $parametres['y'];
if (isset($parametres['width'])) $width = $parametres['width'];
if (isset($parametres['height'])) $height = $parametres['height'];
if (isset($parametres['font_color'])) $vFgColor = $parametres['font_color'];
if (isset($parametres['background_color'])) $vBgColor = $parametres['background_color'];
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB'];
if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB'];
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);
// 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)
);
$gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors);
for($i=0;$i<$nb_colors;$i++)
{
$rgbval = ColorGradient::hex2rgb($gradient[$i]);
$vColor[$i] = new ColorGradient();
$vColor[$i]->pct = ($i*1.0) / $nb_colors;
$vColor[$i]->color = imagecolorallocatealpha($vImage, $rgbval[0], $rgbval[1], $rgbval[2], $alpha);
}
// Récup des données
$data = blockchain::getTransactionData($the_block, $type);
$n_data = count($data);
// ---
// --- On se limite à 40 000 traits
// --- Pour des questions de performance
// ---
while(($n_data * $local_iterations)>40000) $local_iterations--;
// Un calculateur de Spline
$oCurve = new CubicSplines();
// Calcul des min max
foreach($data as $v)
{
if ($v['value'] > $max) $max = $v['value'];
if (($v['value'] < $min)||($min == -1)) $min = $v['value'];
$somme += $v['value'];
}
if ($min == $max) $max = $min + 1;
if ($somme == 0) return;
// On se prend une plus grosse marge en hauteur
$coef = ($height - (4*$marge_y)) / $somme;
$limite_x = $x + ($width - (2*$marge_x));
$dx = round(($width - (2*$marge_x)) / (TX_HASH_LEN+10));
$special_draw = (count($data) == 1);
while($local_iterations-- > 0)
{
$h0 = 0;
$hauteur = $y + (2*$marge_y);
foreach($data as $transaction)
{
//
// La nouvelle hauteur : cumule des montants de transaction
//
$hauteur += $coef * $transaction['value'];
//
// Cas des blocks qui n'ont qu'une seule transaction
// On se cale au milieu
//
if ($special_draw) $hauteur = $y + ($height / 2);
//
// Ne pas tracer 2 lignes à la même hauteur
// => c'est possible du fait de l'arrondi
// si la transaction a un montant faible
//
if ((floor($hauteur)-$h0)<2) continue;
$h0 = floor($hauteur);
$x0 = $x + $marge_x;
//
// On découpe la ligne en fonction du nombre de DIGIT
// dans le hash des transactions
//
$facteur = 0.1;
$aCoords = array();
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
for ($i = 0; $i < TX_HASH_LEN; $i++)
{
$y0 = $h0;
$valeur = hexdec($the_block->hash[$i]);
if ($valeur != 0)
{
$decal = 15.0 * ($i / TX_HASH_LEN);
$valeur += rand(0, floor($decal));
$valeur /= 2;
$valeur -= 8;
$y0 = $h0 + ($valeur * $facteur);
}
if ($y0 < $y+$marge_y) $y0 = $y+$marge_y;
if ($y0 > ($y+$height-$marge_y)) $y0 = $y+$height-$marge_y;
$x0 += $dx;
$aCoords[$x0] = $y0;
if ($y0 == $h0) continue;
$facteur = 0.1 + (($facteur_max*$i) / TX_HASH_LEN);
if ($facteur > $facteur_max) $facteur = $facteur_max;
}
if ($oCurve)
{
$oCurve->setInitCoords($aCoords);
$r = $oCurve->processCoords();
if ($r)
{
$curveGraph = new Plot($r);
$curveGraph->drawLine($vImage, $vColor, $x0, $limite_x);
}
}
}
}
}
?>

118
methode2/robot.php Normal file
View File

@@ -0,0 +1,118 @@
<?php
// ---
// --- Par défaut, on trace de lignes
// ---
$methode='line';
if (isset($argv[1])) $methode = $argv[1];
// ---
// --- La config globale
// ---
require_once '../global/inc/config.php';
// ---
// --- External dependances
// ---
require TOPISTO_PATH.'/ressources/vendor/autoload.php';
require_once '../global/inc/colors.php';
require_once '../global/inc/cubic.php';
// ---
// --- Internal dependances
// ---
require_once APP_PATH.'/blockchain/inc/block.php';
require_once $methode.'/draw.php';
// ---
// --- Par défaut on cherche le dernier block
// --- Le cas échéant, on cherche block passé en argument
// ---
$block_hash = 'LAST';
if (isset($argv[2])) $block_hash = $argv[2];
// ---
// --- Par défaut mode 8
// ---
$mode=8;
if (isset($argv[3])) $mode=intval($argv[3]);
// ---
// --- Par défaut mode 8
// ---
$taille=1;
if (isset($argv[4])) $taille=intval($argv[4]);
$the_block = blockchain::getBlockWithHash($block_hash);
if ($the_block === FALSE) die();
$the_name = blockchain::hash2SpecialName($the_block->hash);
if ($the_name == $the_block->hash) $the_name ='';
$bandeau = 50;
$marge = 25;
$text_border = 20;
$width = GRAPH_WIDTH * $taille;
$height = GRAPH_HEIGHT * $taille;
$couleur = -1; // Au hasard
// Exception : pour hashes2 on dessine un petit bloc
if ($methode == 'hashes2') $height = 2;
// Exception : pour mondrian on prend unbloc en noir et blanc
if ($methode == 'mondrian') $couleur = 9;
// Pour que l'image simple ait les proportions que l'image full
$width = $marge + ($width*2) + (2*$text_border);
$height = $marge + ($height*2);
$img_w = $width;
$img_h = $height+(2*$bandeau);
// création d'une image plus haute pour inclure bandeaux haut et bas
$img = imagecreatetruecolor($img_w, $img_h);
// ---
// --- On dessine les inputs, sauf pour les blocks ne contenanty que la récompense
// ---
$type=2;
if (count($the_block->tx)==1) $type = 4;
$paramHeader = blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau, $couleur);
imagefilledrectangle($img, 0, $bandeau, $width, $bandeau + $height, $paramHeader[1]);
imageline($img, 0, 5, 0, $img_h-25, $paramHeader[2]);
imageline($img, $width-1, 5, $width-1, $img_h-25, $paramHeader[2]);
$parametres = [];
$parametres['x'] = 0;
$parametres['y'] = $bandeau;
$parametres['width'] = $width;
$parametres['height'] = $height;
$parametres['methode'] = 5;
$parametres['type'] = $type;
$parametres['iterations'] = 10;
$parametres['transparent_color'] = $paramHeader[0];
$parametres['background_color'] = $paramHeader[1];
$parametres['font_color'] = $paramHeader[2];
$parametres['fontname'] = $paramHeader[3];
$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) {
$parametres['background_color'] = $paramHeader[2];
$parametres['background_RGB'] = $paramHeader[4];
$parametres['font_color'] = $paramHeader[1];
$parametres['font_RGB'] = $paramHeader[5];
}
DrawBlock($the_block, $img, $parametres);
$imagepath = 'big';
if ($taille == 1) $imagepath = 'last';
imagepng($img, DATA_PATH.'/'.$imagepath.'/'.$the_block->hash.'.png');
imagedestroy($img);
?>

52
methode2/robot.sh Executable file
View File

@@ -0,0 +1,52 @@
#!/bin/bash
METHODE=$1
flag=$TMP_PATH/${METHODE}_bot.flag
date=`date +%Y%m%d0000`
if [ ! -d $APPS_PATH/methode2/$METHODE ];
then
echo $APPS_PATH/methode2/$METHODE introuvable ...
exit 1
fi
if [ -f $flag ];
then
echo "$METHODE_bot is already running !"
exit 0
fi
touch $flag
if [ ! -d $DATA_PATH/$METHODE ];
then
mkdir -p $DATA_PATH/$METHODE
fi
cd $APPS_PATH/methode2
for BLOCK in `awk '{print $2}' $DATA_PATH/block_list.txt`
do
if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ]
then
php robot.php $1 $BLOCK $((RANDOM % 6)) $2
if [ "$2" == "" ];
then
rm -f $DATA_PATH/hasard/$BLOCK.png
ln $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png
ln $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
fi
fi
if [ -f $DATA_PATH/$METHODE/$BLOCK.png ]
then
BNAME=`grep $BLOCK $DATA_PATH/block_list.txt | awk '{print $1}'`
if [ "$BNAME" == "LAST" ]
then
touch $DATA_PATH/$METHODE/$BLOCK.png
else
touch -t $date $DATA_PATH/$METHODE/$BLOCK.png
fi
fi
done
rm -f $flag

View File

@@ -0,0 +1,156 @@
<?php
function DrawBlock($the_block, $vImage, $parametres)
{
// valeurs par défaut
$type = 1;
// Ces variables vont permettre de caler les lignes
// dans la zone de dessin en se laissant des marges
// en haut et en bas
$somme = 0;
$min =-1;
$max = 0;
$marge_x = 10;
$marge_y = 10;
$facteur_max = 2.5;
// Détermine si on dessine les tx, les fees ou la récompense
if (isset($parametres['type'])) $type = $parametres['type'];
// Paramètres de dessin
if (isset($parametres['x'])) $x = $parametres['x'];
if (isset($parametres['y'])) $y = $parametres['y'];
if (isset($parametres['width'])) $width = $parametres['width'];
if (isset($parametres['height'])) $height = $parametres['height'];
if (isset($parametres['font_color'])) $vFgColor = $parametres['font_color'];
if (isset($parametres['background_color'])) $vBgColor = $parametres['background_color'];
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);
// 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)
);
$gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors);
for($i=0;$i<$nb_colors;$i++)
{
$rgbval = ColorGradient::hex2rgb($gradient[$i]);
$vColor[$i] = new ColorGradient();
$vColor[$i]->pct = ($i*1.0) / $nb_colors;
$vColor[$i]->color = imagecolorallocate($vImage, $rgbval[0], $rgbval[1], $rgbval[2]);
}
// Récup des données
$data = blockchain::getTransactionData($the_block, $type);
$n_data = count($data);
// Un calculateur de Spline
$oCurve = new CubicSplines();
// Calcul des min max
foreach($data as $v)
{
if ($v['value'] > $max) $max = $v['value'];
if (($v['value'] < $min)||($min == -1)) $min = $v['value'];
$somme += $v['value'];
}
if ($min == $max) $max = $min + 1;
if ($somme == 0) return;
// On se prend une plus grosse marge en hauteur
$coef = ($height - (4*$marge_y)) / $somme;
$limite_x = $x + ($width - (2*$marge_x));
$dx = round(($width - (2*$marge_x)) / (TX_HASH_LEN+10));
$h0 = 0;
$hauteur = $y + (2*$marge_y);
$special_draw = (count($data) == 1);
foreach($data as $transaction)
{
//
// La nouvelle hauteur : cumule des montants de transaction
//
$hauteur += $coef * $transaction['value'];
//
// Cas des blocks qui n'ont qu'une seule transaction
// On se cale au milieu
//
if ($special_draw) $hauteur = $y + ($height / 2);
//
// Ne pas tracer 2 lignes à la même hauteur
// => c'est possible du fait de l'arrondi
// si la transaction a un montant faible
//
if ((floor($hauteur)-$h0)<2) continue;
$h0 = floor($hauteur);
$x0 = $x + $marge_x;
//
// On découpe la ligne en fonction du nombre de DIGIT
// dans le hash des transactions
//
$facteur = 0.1;
$aCoords = array();
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
for ($i = 0; $i < TX_HASH_LEN; $i++)
{
$y0 = $h0;
$valeur = hexdec($transaction['hash'][$i]);
if ($valeur != 0) $y0 += floor(($valeur - 8) * $facteur);
if ($y0 < $y+$marge_y) $y0 = $y+$marge_y;
if ($y0 > ($y+$height-$marge_y)) $y0 = $y+$height-$marge_y;
$x0 += $dx;
$aCoords[$x0] = $y0;
if ($y0 == $h0) continue;
$facteur = 0.1 + (($facteur_max*$i) / TX_HASH_LEN);
if ($facteur > $facteur_max) $facteur = $facteur_max;
}
if ($oCurve)
{
$oCurve->setInitCoords($aCoords);
$r = $oCurve->processCoords();
if ($r)
{
$curveGraph = new Plot($r);
$curveGraph->drawLine($vImage, $vColor, $x0, $limite_x);
}
}
}
}
?>

View File

@@ -0,0 +1,181 @@
<?php
function DrawBlock($the_block, $vImage, $parametres)
{
// valeurs par défaut
$type = 1;
// Ces variables vont permettre de caler les lignes
// dans la zone de dessin en se laissant des marges
// en haut et en bas
$somme = 0;
$min =-1;
$max = 0;
$marge_x = 10;
$marge_y = 10;
$facteur_max = 2.5;
$local_iterations = 100;
// Détermine si on dessine les tx, les fees ou la récompense
if (isset($parametres['type'])) $type = $parametres['type'];
// Paramètres de dessin
if (isset($parametres['x'])) $x = $parametres['x'];
if (isset($parametres['y'])) $y = $parametres['y'];
if (isset($parametres['width'])) $width = $parametres['width'];
if (isset($parametres['height'])) $height = $parametres['height'];
if (isset($parametres['font_color'])) $vFgColor = $parametres['font_color'];
if (isset($parametres['background_color'])) $vBgColor = $parametres['background_color'];
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB'];
if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB'];
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);
// 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)
);
$gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors);
for($i=0;$i<$nb_colors;$i++)
{
$rgbval = ColorGradient::hex2rgb($gradient[$i]);
$vColor[$i] = new ColorGradient();
$vColor[$i]->pct = ($i*1.0) / $nb_colors;
$vColor[$i]->color = imagecolorallocatealpha($vImage, $rgbval[0], $rgbval[1], $rgbval[2], $alpha);
}
// Récup des données
$data = blockchain::getTransactionData($the_block, $type);
$n_data = count($data);
// ---
// --- On se limite à 40 000 traits
// --- Pour des questions de performance
// ---
while(($n_data * $local_iterations)>40000) $local_iterations--;
// Un calculateur de Spline
$oCurve = new CubicSplines();
// Calcul des min max
foreach($data as $v)
{
if ($v['value'] > $max) $max = $v['value'];
if (($v['value'] < $min)||($min == -1)) $min = $v['value'];
$somme += $v['value'];
}
if ($min == $max) $max = $min + 1;
if ($somme == 0) return;
// On se prend une plus grosse marge en hauteur
$coef = ($height - (4*$marge_y)) / $somme;
$limite_x = $x + ($width - (2*$marge_x));
$dx = round(($width - (2*$marge_x)) / (TX_HASH_LEN+10));
$special_draw = (count($data) == 1);
while($local_iterations-- > 0)
{
$h0 = 0;
$hauteur = $y + (2*$marge_y);
foreach($data as $transaction)
{
//
// La nouvelle hauteur : cumule des montants de transaction
//
$hauteur += $coef * $transaction['value'];
//
// Cas des blocks qui n'ont qu'une seule transaction
// On se cale au milieu
//
if ($special_draw) $hauteur = $y + ($height / 2);
//
// Ne pas tracer 2 lignes à la même hauteur
// => c'est possible du fait de l'arrondi
// si la transaction a un montant faible
//
if ((floor($hauteur)-$h0)<2) continue;
$h0 = floor($hauteur);
$x0 = $x + $marge_x;
//
// On découpe la ligne en fonction du nombre de DIGIT
// dans le hash des transactions
//
$facteur = 0.1;
$aCoords = array();
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
$aCoords[$x0] = $h0; $x0 += $dx;
for ($i = 0; $i < TX_HASH_LEN; $i++)
{
$y0 = $h0;
$valeur = hexdec($transaction['hash'][$i]);
if ($valeur != 0)
{
$decal = 15.0 * ($i / TX_HASH_LEN);
$valeur += rand(0, floor($decal));
$valeur /= 2;
$valeur -= 8;
$y0 = $h0 + ($valeur * $facteur);
}
if ($y0 < $y+$marge_y) $y0 = $y+$marge_y;
if ($y0 > ($y+$height-$marge_y)) $y0 = $y+$height-$marge_y;
$x0 += $dx;
$aCoords[$x0] = $y0;
if ($y0 == $h0) continue;
$facteur = 0.1 + (($facteur_max*$i) / TX_HASH_LEN);
if ($facteur > $facteur_max) $facteur = $facteur_max;
}
if ($oCurve)
{
$oCurve->setInitCoords($aCoords);
$r = $oCurve->processCoords();
if ($r)
{
$curveGraph = new Plot($r);
$curveGraph->drawLine($vImage, $vColor, $x0, $limite_x);
}
}
}
}
}
?>

View File

@@ -0,0 +1,55 @@
<?php
use codeagent\treemap\Treemap;
use codeagent\treemap\presenter\ImagePresenter;
use codeagent\treemap\presenter\NodeInfo;
function DrawBlock($the_block, $vImage, $parametres)
{
$type = 1;
if (isset($parametres['x'])) $x = $parametres['x'];
if (isset($parametres['y'])) $y = $parametres['y'];
if (isset($parametres['width'])) $width = $parametres['width'];
if (isset($parametres['height'])) $height = $parametres['height'];
if (isset($parametres['methode'])) $mode = $parametres['methode'];
if (isset($parametres['type'])) $type = $parametres['type'];
if (isset($parametres['font_color'])) $vBgColor = $parametres['font_color'];
if (isset($parametres['background_color'])) $vFgColor = $parametres['background_color'];
imagefilledrectangle($vImage, $x, $y, $x+$width, $y+$height, $vFgColor);
$full_area = $width * $height;
if ($full_area == 0) $full_area = 1;
$data = blockchain::getTransactionData($the_block, $type);
$treemap = new Treemap($data, $width, $height);
$map = $treemap->getMap();
$m = count($map);
$flag_contour = true;
for($mm = 0; $mm < $m; $mm++)
{
$tx = $map[$mm];
$factor = (($tx['_rectangle']->width * $tx['_rectangle']->height) / $full_area)*100.0;
$x1 = $x + $tx['_rectangle']->left;
$y1 = $y + $tx['_rectangle']->top;
$x2 = $x1 + $tx['_rectangle']->width;
$y2 = $y1 + $tx['_rectangle']->height;
if ($x1 > ($x+$width)) $x1 = ($x+$width);
if ($y1 > ($y+$height)) $y1 = ($y+$height);
if ($x2 > ($x+$width)) $x2 = ($x+$width);
if ($y2 > ($y+$height)) $y2 = ($y+$height);
if (($x2 - $x1) < 3) break;
if (($y2 - $y1) < 3) break;
imagerectangle($vImage, $x1, $y1, $x2, $y2, $vBgColor);
}
if ($mm < $m) imagerectangle($vImage, $x1, $y1, $x+$width, $y+$height, $vBgColor);
}
?>

View File

@@ -0,0 +1,95 @@
<?php
use codeagent\treemap\Treemap;
use codeagent\treemap\presenter\ImagePresenter;
use codeagent\treemap\presenter\NodeInfo;
use codeagent\treemap\Gradient;
function DrawBlock($the_block, $vImage, $parametres)
{
$type = 1;
if (isset($parametres['x'])) $x = $parametres['x'];
if (isset($parametres['y'])) $y = $parametres['y'];
if (isset($parametres['width'])) $width = $parametres['width'];
if (isset($parametres['height'])) $height = $parametres['height'];
if (isset($parametres['methode'])) $mode = $parametres['methode'];
if (isset($parametres['type'])) $type = $parametres['type'];
if (isset($parametres['font_color'])) $vFgColor = $parametres['font_color'];
if (isset($parametres['background_color'])) $vBgColor = $parametres['background_color'];
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB'];
if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB'];
$min =-1;
$max = 0;
$data = blockchain::getTransactionData($the_block, $type);
// Inverser foreground et Background
imagefilledrectangle($vImage, $x, $y, $x+$width, $y+$height, $vFgColor);
$vFgColor = imagecolorallocatealpha($vImage, $vBgRGB[0], $vBgRGB[1], $vBgRGB[2], 125);
//$vBgColor = imagecolorallocate($vImage, 10, 10, 10);
//imagefilledrectangle($vImage, $x, $y, $x+$width, $y+$height, $vBgColor);
// Calcul des min max
foreach($data as $v)
{
if ($v['value'] > $max) $max = $v['value'];
if (($v['value'] < $min)||($min == -1)) $min = $v['value'];
}
if ($min == $max) $max = $min + 1;
$treemap = new Treemap($data, $width, $height);
$map = $treemap->getMap();
$mm = count($map);
$mmax = $mm - 30;
foreach($map as $tx)
{
$x1 = $x + $tx['_rectangle']->left;
$y1 = $y + $tx['_rectangle']->top;
if (($tx['_rectangle']->height < 2)&&($tx['_rectangle']->width < 2))
{
imagesetpixel($vImage, $x1, $y1, $vFgColor);
} else {
$x2 = $x1;
$y2 = $y1 + $tx['_rectangle']->height;
// if ($y2 >= ($height-$bandeau)) $y2 = ($height - $bandeau) - 1;
$x3 = $x1 + $tx['_rectangle']->width;
$y3 = $y2;
$x4 = $x3;
$y4 = $y1;
// ----
$w = floor($tx['_rectangle']->width / 4);
$h = floor($tx['_rectangle']->height / 4);
$ww = floor(200*($mm/$mmax));
$ww = floor(($h * $w)*0.8);
if ($ww < 1) $ww = 1;
for($i=0;$i<$ww;$i++)
{
$x1_1 = $x1 + floor($w*( rand(0, 100) / 100));
$y1_1 = $y1 + floor($h*( rand(0, 100) / 100));
$x2_1 = $x2 + floor($w*( rand(0, 100) / 100));
$y2_1 = $y2 - floor($h*( rand(0, 100) / 100));
$x3_1 = $x3 - floor($w*( rand(0, 100) / 100));
$y3_1 = $y3 - floor($h*( rand(0, 100) / 100));
$x4_1 = $x4 - floor($w*( rand(0, 100) / 100));
$y4_1 = $y4 + floor($h*( rand(0, 100) / 100));
imageline($vImage, $x1_1, $y1_1, $x2_1, $y2_1, $vFgColor);
imageline($vImage, $x2_1, $y2_1, $x3_1, $y3_1, $vFgColor);
imageline($vImage, $x3_1, $y3_1, $x4_1, $y4_1, $vFgColor);
imageline($vImage, $x4_1, $y4_1, $x1_1, $y1_1, $vFgColor);
}
}
$mm -= 1;
}
}
?>