|
|
<?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;
|
|
|
$alpha = 0;
|
|
|
|
|
|
// 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), $vFgColor);
|
|
|
|
|
|
// Dégradé de 360 couleurs entre la couleur de dessin et le blanc
|
|
|
$nbColor = 360;
|
|
|
$vColor = getGDcolorGradientArray($vImage, $nbColor, $vBgRGB, $vFgRGB, $alpha);
|
|
|
|
|
|
// Récup des données
|
|
|
$data = blockchain::getTransactionData($the_block, $type);
|
|
|
|
|
|
$xc = $x + ($width / 2);
|
|
|
$yc = $y + ($height / 2);
|
|
|
|
|
|
$mini=$height/6.4;
|
|
|
$maxi=$height/3.2;
|
|
|
$angle=0;
|
|
|
$ppas=2000.0;
|
|
|
$pas=360.0/TX_HASH_LEN;
|
|
|
$pas /= $ppas;
|
|
|
|
|
|
for($i=0;$i<TX_HASH_LEN;$i++)
|
|
|
{
|
|
|
$valeur = hexdec($the_block->hash[$i]);
|
|
|
$r = $mini;
|
|
|
$r += ($maxi*(($valeur+1.0)/16.0));
|
|
|
|
|
|
$xi = $xc + $r*cos(deg2rad($angle));
|
|
|
$yi = $yc + $r*sin(deg2rad($angle));
|
|
|
|
|
|
for($ii=0;$ii<$ppas;$ii++)
|
|
|
{
|
|
|
|
|
|
$xi = $xc + $r*cos(deg2rad($angle));
|
|
|
$yi = $yc + $r*sin(deg2rad($angle));
|
|
|
|
|
|
imageline($vImage, $xc, $yc, $xi, $yi, $vColor[abs(floor(180-$angle))]->color);
|
|
|
|
|
|
$angle += $pas;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
?>
|