réorg
This commit is contained in:
22
big.sh
Executable file
22
big.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# VARIABLES
|
||||
#
|
||||
export APPS_PATH=`dirname "$(readlink -f "$0")"`
|
||||
export TMP_PATH=$APPS_PATH/../tmp
|
||||
export DATA_PATH=$APPS_PATH/../data
|
||||
export FLAG_PATH=$APPS_PATH/../flags
|
||||
|
||||
MINUTE=`date +%M`
|
||||
DATE=`date +%Y%m%d0000`
|
||||
|
||||
if [ -f methode/$1/robot.sh ];
|
||||
then
|
||||
source methode/$1/robot.sh
|
||||
else
|
||||
source methode2/robot.sh $1 4
|
||||
fi
|
||||
|
||||
#source twitter/twitterbot/robot.sh
|
||||
|
||||
@@ -32,7 +32,9 @@ class blockchain
|
||||
'BCC' => '00000000000000000019f112ec0a9982926f1258cdcc558dd7c3b7e5dc7fa148',
|
||||
'SEGWIT_LOCK' => '0000000000000000012e6060980c6475a9a8e62a1bf44b76c5d51f707d54522c',
|
||||
'SEGWIT' => '000000000000000000cbeff0b533f8e1189cf09dfbebf57a8ebe349362811b80',
|
||||
'HURRICANE_1' => '0000000000000000000fe6d521a187a5523d5cef6f6c178923ff82ffe5a0f372'
|
||||
'HURRICANE_1' => '0000000000000000000fe6d521a187a5523d5cef6f6c178923ff82ffe5a0f372',
|
||||
'WHALE201810' => '0000000000000000000f9f2dadfb8f312572183272802cbfcc4ff95b4ee6777d',
|
||||
'BLOCK21E800' => '00000000000000000021e800c1e8df51b22c1588e5a624bea17e9faa34b2dc4a'
|
||||
);
|
||||
|
||||
// ---
|
||||
@@ -211,7 +213,7 @@ class blockchain
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public static function DrawBlockHeaderFooter($the_block, $vImage, $hauteur)
|
||||
public static function DrawBlockHeaderFooter($the_block, $vImage, $hauteur, $couleur = -1)
|
||||
{
|
||||
$color_tab = [
|
||||
[
|
||||
@@ -250,13 +252,22 @@ class blockchain
|
||||
[40, 40, 40],
|
||||
[158,227,253]
|
||||
],
|
||||
[
|
||||
[255, 255, 255],
|
||||
[0, 0, 0]
|
||||
],
|
||||
[
|
||||
[0, 0, 0],
|
||||
[255, 255, 255]
|
||||
],
|
||||
[
|
||||
[255, 255, 255],
|
||||
[255, 0, 0]
|
||||
]
|
||||
];
|
||||
|
||||
$color = rand(0,count($color_tab)-1);
|
||||
$color = $couleur;
|
||||
if ($color == -1) $color = rand(0,count($color_tab)-1);
|
||||
|
||||
// Rajout des HASHES
|
||||
$white = imagecolorallocate($vImage, 254, 254, 254);
|
||||
@@ -272,7 +283,7 @@ class blockchain
|
||||
imagefilledrectangle($vImage, 0, 0, $w, $h, $white);
|
||||
|
||||
$len = strlen($the_block->hash);
|
||||
$ratio_w = $w / $len;
|
||||
$ratio_w = ($w - 10) / $len;
|
||||
$ratio_h = $hauteur / 32; // car hexadécimal
|
||||
|
||||
// Récupérer les hashes dans 2 tableaux
|
||||
@@ -295,7 +306,7 @@ class blockchain
|
||||
$coin_x1 = $ratio_w * $i;
|
||||
$coin_x2 = $ratio_w * ($i + 1);
|
||||
$coin_y1 = $hauteur;
|
||||
$coin_y2 = hexdec($tableau1[$i])*$ratio_h;
|
||||
$coin_y2 = 5 + hexdec($tableau1[$i])*$ratio_h;
|
||||
|
||||
$points1[] = $coin_x1;
|
||||
$points1[] = $coin_y2;
|
||||
@@ -306,7 +317,7 @@ class blockchain
|
||||
$coin_x1 = $ratio_w * $i;
|
||||
$coin_x2 = $ratio_w * ($i + 1);
|
||||
$coin_y1 = $hauteur;
|
||||
$coin_y2 = 16 - (hexdec($tableau2[$i])*$ratio_h);
|
||||
$coin_y2 = 25 - hexdec($tableau2[$i])*$ratio_h;
|
||||
|
||||
$points2[] = $coin_x1;
|
||||
$points2[] = $coin_y2;
|
||||
@@ -314,6 +325,28 @@ class blockchain
|
||||
$points2[] = $coin_y2;
|
||||
}
|
||||
|
||||
// Rajouter une barre au HASH
|
||||
$coin_x1 = $ratio_w * $i;
|
||||
$coin_x2 = $ratio_w * ($i + 1);
|
||||
$coin_y1 = $hauteur;
|
||||
$coin_y2 = 5;
|
||||
|
||||
$points1[] = $coin_x1;
|
||||
$points1[] = $coin_y2;
|
||||
$points1[] = $coin_x2;
|
||||
$points1[] = $coin_y2;
|
||||
|
||||
// Rajouter une barre au PREV HASH
|
||||
$coin_x1 = $ratio_w * $i;
|
||||
$coin_x2 = $ratio_w * ($i + 1);
|
||||
$coin_y1 = $hauteur;
|
||||
$coin_y2 = 25;
|
||||
|
||||
$points2[] = $coin_x1;
|
||||
$points2[] = $coin_y2;
|
||||
$points2[] = $coin_x2;
|
||||
$points2[] = $coin_y2;
|
||||
|
||||
// Rajouter un coin
|
||||
$points1[] = $w;
|
||||
$points1[] = $hauteur - 1;
|
||||
@@ -324,7 +357,7 @@ class blockchain
|
||||
// Inverser le PREV HASH
|
||||
for($i=0;$i<count($points2);$i+=2)
|
||||
{
|
||||
$points2[$i+1] = ($h - 12) - $points2[$i+1];
|
||||
$points2[$i+1] = $h - $points2[$i+1];
|
||||
if ($points2[$i+1] >= $h) $points2[$i+1] = $h - 1;
|
||||
}
|
||||
|
||||
@@ -332,12 +365,10 @@ class blockchain
|
||||
imagefilledpolygon($vImage, $points1, (count($points1)/2), $fond);
|
||||
imagepolygon($vImage, $points1, (count($points1)/2), $black);
|
||||
|
||||
// dessiner le PREV HASH
|
||||
// Dessiner le PREV HASH
|
||||
imagefilledpolygon($vImage, $points2, (count($points2)/2), $fond);
|
||||
imagepolygon($vImage, $points2, (count($points2)/2), $black);
|
||||
|
||||
imagefilledrectangle($vImage, 0, $hauteur, $w, $h-$hauteur, $black);
|
||||
|
||||
// Rajout des textes
|
||||
$the_name = blockchain::hash2SpecialName($the_block->hash);
|
||||
if ($the_name == $the_block->hash) $the_name = date('Ymd H:i:s', $the_block->time);
|
||||
|
||||
@@ -11,6 +11,14 @@ export FLAG_PATH=$APPS_PATH/../flags
|
||||
MINUTE=`date +%M`
|
||||
DATE=`date +%Y%m%d0000`
|
||||
|
||||
if [ -f methode/$1/robot.sh ];
|
||||
then
|
||||
source methode/$1/robot.sh
|
||||
fi
|
||||
|
||||
if [ -d methode2/$1 ];
|
||||
then
|
||||
source methode2/robot.sh $1
|
||||
fi
|
||||
#source twitter/twitterbot/robot.sh
|
||||
|
||||
|
||||
15
lancer2.sh
Executable file
15
lancer2.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# VARIABLES
|
||||
#
|
||||
export APPS_PATH=`dirname "$(readlink -f "$0")"`
|
||||
export TMP_PATH=$APPS_PATH/../tmp
|
||||
export DATA_PATH=$APPS_PATH/../data
|
||||
export FLAG_PATH=$APPS_PATH/../flags
|
||||
|
||||
MINUTE=`date +%M`
|
||||
DATE=`date +%Y%m%d0000`
|
||||
|
||||
source scripts/blocks2.sh
|
||||
|
||||
@@ -51,7 +51,12 @@ $img_h = $height+(2*$bandeau);
|
||||
// création d'une image plus haute pour inclure bandeaux haut et bas
|
||||
$img = imagecreatetruecolor($img_w, $img_h);
|
||||
|
||||
blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
|
||||
$paramHeader = blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
|
||||
|
||||
imagefilledrectangle($img, 0, $bandeau, $width, $bandeau + $height, $paramHeader[2]);
|
||||
|
||||
imagefilledrectangle($img, 0, 0, 0, $img_h, $paramHeader[2]);
|
||||
imagefilledrectangle($img, $img_w-1, 0, $img_w-1, $img_h, $paramHeader[2]);
|
||||
|
||||
imagepng($img, DATA_PATH.'/hashes/'.$the_block->hash.'.png');
|
||||
|
||||
|
||||
@@ -1,40 +1,32 @@
|
||||
#!/bin/bash
|
||||
flag=$TMP_PATH/hashes_bot.flag
|
||||
METHODE=hashes
|
||||
flag=$TMP_PATH/${METHODE}_bot.flag
|
||||
date=`date +%Y%m%d0000`
|
||||
|
||||
if [ -f $flag ];
|
||||
then
|
||||
echo "hashes_bot is already running !"
|
||||
echo "${METHODE}_bot is already running !"
|
||||
exit 0
|
||||
fi
|
||||
touch $flag
|
||||
|
||||
cd $APPS_PATH/methode/hashes
|
||||
cd $APPS_PATH/methode/$METHODE
|
||||
for BLOCK in `grep LAST $DATA_PATH/block_list.txt | awk '{print $2}'`
|
||||
do
|
||||
if [ ! -f $DATA_PATH/hashes/$BLOCK.png ]
|
||||
if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ]
|
||||
then
|
||||
BLOCK_HEIGHT=`grep $BLOCK $DATA_PATH/block_list.txt | awk '{print $3}'`
|
||||
php robot.php $BLOCK $((RANDOM % 6))
|
||||
|
||||
echo $BLOCK_HEIGHT $BLOCK >> $DATA_PATH/hashes2hashes/liste.txt
|
||||
mv $DATA_PATH/hashes2hashes/liste.txt $DATA_PATH/hashes2hashes/liste.new
|
||||
sort -k1 -n $DATA_PATH/hashes2hashes/liste.new > $DATA_PATH/hashes2hashes/liste.txt
|
||||
rm -f $DATA_PATH/hashes2hashes/liste.new
|
||||
COMPTEUR=`wc -l $DATA_PATH/hashes2hashes/liste.txt | awk '{print $1}' `
|
||||
if [ $COMPTEUR -eq 6 ]
|
||||
then
|
||||
php assemble.php
|
||||
rm -f $DATA_PATH/hashes2hashes/liste.old
|
||||
mv $DATA_PATH/hashes2hashes/liste.txt $DATA_PATH/hashes2hashes/liste.old
|
||||
fi
|
||||
fi
|
||||
|
||||
BNAME=`grep $BLOCK $DATA_PATH/block_list.txt | awk '{print $1}'`
|
||||
if [ "$BNAME" == "LAST" ]
|
||||
then
|
||||
touch $DATA_PATH/hashes/$BLOCK.png
|
||||
touch $DATA_PATH/$METHODE/$BLOCK.png
|
||||
else
|
||||
touch -t $date $DATA_PATH/hashes/$BLOCK.png
|
||||
touch -t $date $DATA_PATH/$METHODE/$BLOCK.png
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
30
methode/hashes2hashes/robot.sh
Executable file
30
methode/hashes2hashes/robot.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
METHODE=hashes2hashes
|
||||
flag=$TMP_PATH/${METHODE}_bot.flag
|
||||
date=`date +%Y%m%d0000`
|
||||
|
||||
if [ -f $flag ];
|
||||
then
|
||||
echo "${METHODE}_bot is already running !"
|
||||
exit 0
|
||||
fi
|
||||
touch $flag
|
||||
|
||||
cd $APPS_PATH/methode/$METHODE
|
||||
|
||||
mv $DATA_PATH/$METHODE/liste.txt $DATA_PATH/$METHODE/liste.new
|
||||
sort -k1 -n $DATA_PATH/$METHODE/liste.new > $DATA_PATH/$METHODE/liste.txt
|
||||
rm -f $DATA_PATH/$METHODE/liste.new
|
||||
|
||||
BLOCK=`head -n 1 $DATA_PATH/$METHODE/liste.txt | awk '{print $2}'`
|
||||
COMPTEUR=`wc -l $DATA_PATH/$METHODE/liste.txt | awk '{print $1}'`
|
||||
|
||||
if [ $COMPTEUR -gt 5 ]
|
||||
then
|
||||
php robot.php
|
||||
|
||||
rm -f $DATA_PATH/$METHODE/liste.old
|
||||
mv $DATA_PATH/$METHODE/liste.txt $DATA_PATH/$METHODE/liste.old
|
||||
fi
|
||||
|
||||
rm -f $flag
|
||||
@@ -1,409 +0,0 @@
|
||||
<?php
|
||||
|
||||
class topisto_spline2
|
||||
{
|
||||
|
||||
public static function DefaultDrawBlock($the_block, $vImage, $x, $y, $graph_width, $graph_height, $type=1)
|
||||
{
|
||||
topisto_spline2::DrawBlock($the_block, $vImage, $x, $y, $graph_width, $graph_height, 3.5, 1, $type);
|
||||
topisto_spline2::DrawBlock($the_block, $vImage, $x, $y, $graph_width, $graph_height, 5, 30, $type);
|
||||
}
|
||||
|
||||
//
|
||||
// modes
|
||||
// - 0 : une droite de couleur uniforme
|
||||
// - 1 : une droite en dégradé de couleur
|
||||
// - 2 : une spline en dégradé de couleur passant les valeurs du hash de la transaction
|
||||
// - 3 : la spline dessinée en 2 est atténuée à gauche et amplifiée à droite
|
||||
// - 3.5 : idem mode 3, mais avec de la transparence
|
||||
// - 4 : $iterations splines oscillants autour de la spline dessinée en 2
|
||||
// - 4.5 : les splines sont desssinées en transparence
|
||||
//
|
||||
public static function DrawBlock($the_block, $vImage, $parametres)
|
||||
{
|
||||
|
||||
return topisto_spline2::DrawLine($the_block, $vImage, $parametres);
|
||||
|
||||
$somme = 0;
|
||||
$min =-1;
|
||||
$max = 0;
|
||||
$type = 1;
|
||||
$local_iterations = 200;
|
||||
|
||||
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['iterations'])) $local_iterations = $parametres['iterations'];
|
||||
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'];
|
||||
|
||||
$local_iterations = 150;
|
||||
|
||||
$data = blockchain::getTransactionData($the_block, $type);
|
||||
$n_data = count($data);
|
||||
|
||||
$fond = $vBgColor;
|
||||
if (rand(0,100) < 50) $fond = $vFgColor;
|
||||
imagefilledrectangle($vImage, $x, $y, $x+$width-1, $y+$height-1, $fond);
|
||||
|
||||
// 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 limite à 40 000 traits
|
||||
// --- Pour des questions de performance
|
||||
// ---
|
||||
while(($n_data * $local_iterations)>40000) $local_iterations--;
|
||||
|
||||
$vColor = array();
|
||||
|
||||
// Gestion de la transparence
|
||||
$alpha = 125;
|
||||
if ($mode < 4.5) $alpha = 0;
|
||||
if ($mode == 3.5) $alpha = 100;
|
||||
|
||||
// On choisit des couleurs au hasard
|
||||
$hex_val = array(
|
||||
ColorGradient::rgb2hex([rand(0,255),rand(0,255),rand(0,255)]),
|
||||
ColorGradient::rgb2hex([rand(0,255),rand(0,255),rand(0,255)]),
|
||||
ColorGradient::rgb2hex([rand(0,255),rand(0,255),rand(0,255)])
|
||||
);
|
||||
// Dégradé de couleurs entre bgcolor et blanc
|
||||
$hex_val = array(
|
||||
ColorGradient::rgb2hex([0,0,0]),
|
||||
ColorGradient::rgb2hex($vFgRGB)
|
||||
);
|
||||
|
||||
$gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], TX_HASH_LEN);
|
||||
for($i=0;$i<TX_HASH_LEN;$i++)
|
||||
{
|
||||
$rgbval = ColorGradient::hex2rgb($gradient[$i]);
|
||||
$vColor[$i] = new ColorGradient();
|
||||
$vColor[$i]->pct = ($i*1.0) / TX_HASH_LEN;
|
||||
$vColor[$i]->color = imagecolorallocatealpha($vImage, $rgbval[0], $rgbval[1], $rgbval[2], $alpha);
|
||||
}
|
||||
|
||||
//////////
|
||||
$oCurve = new CubicSplines();
|
||||
|
||||
$marge_x = 10;
|
||||
$marge_y = 20;
|
||||
|
||||
$coef = ($height - (2*$marge_y)) / $somme;
|
||||
$dx = $width;
|
||||
if ($mode > 0) $dx = round($dx / (TX_HASH_LEN+1));
|
||||
|
||||
$limite_x = $x + $width - $marge_x;
|
||||
|
||||
$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
|
||||
//
|
||||
if ($special_draw) $hauteur = $y + ($height / 2);
|
||||
|
||||
//
|
||||
// Ne pas tracer 2 lignes à la même hauteur
|
||||
//
|
||||
if ((floor($hauteur)-$h0)<2) continue;
|
||||
$h0 = floor($hauteur);
|
||||
|
||||
//
|
||||
// On va faire des itérations sur la transaction courante.
|
||||
// A chaque itération, on va s'appuyer sur le hash de la transaction
|
||||
// mais en introduisant du bruit.
|
||||
// On va donc statistiquement tracer une courbe représentant le hash
|
||||
//
|
||||
for($j=0;$j<$local_iterations;$j++)
|
||||
{
|
||||
//
|
||||
// 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, $vColor[0]->color);
|
||||
$x0 += $dx;
|
||||
|
||||
//
|
||||
// Le mode 0 consiste à tracer une droite de couleur uniforme
|
||||
//
|
||||
if (($mode == 0)||($x0 >= $limite_x)) continue;
|
||||
|
||||
$aCoords = array();
|
||||
$facteur = 1;
|
||||
|
||||
if ($mode > 2) $facteur = 0.04;
|
||||
|
||||
//
|
||||
// On découpe la ligne en fonction du nombre de DIGIT
|
||||
// dans le hash des transactions
|
||||
//
|
||||
$aCoords[$x0] = $h0;
|
||||
for ($i = 0; $i < (TX_HASH_LEN-1); $i++)
|
||||
{
|
||||
$y0 = $h0;
|
||||
if ($mode > 1)
|
||||
{
|
||||
$y0 += (hexdec($transaction['hash'][$i]) - 8) * $facteur;
|
||||
$valeur = rand(-16, 16) * $facteur;
|
||||
if ($mode > 2) $facteur += 0.02;
|
||||
if ($mode > 3) $y0 += $valeur;
|
||||
}
|
||||
$x0 += $dx;
|
||||
$aCoords[$x0] = $y0;
|
||||
}
|
||||
if ($oCurve)
|
||||
{
|
||||
$oCurve->setInitCoords($aCoords);
|
||||
$r = $oCurve->processCoords();
|
||||
if ($r)
|
||||
{
|
||||
$curveGraph = new Plot($r);
|
||||
$curveGraph->drawLine($vImage, $vColor, $x0, $limite_x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function DrawLine($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'];
|
||||
|
||||
// Une chance sur deux d'inverser entre fg et bg
|
||||
if (rand(0,100) < 50) {
|
||||
$fond = $vBgColor;
|
||||
$couleur = $vFgColor;
|
||||
} else {
|
||||
$fond = $vFgColor;
|
||||
$couleur = $vBgColor;
|
||||
}
|
||||
|
||||
// Remplir le fond
|
||||
imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond);
|
||||
|
||||
// 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, $couleur);
|
||||
}
|
||||
}
|
||||
|
||||
public static function DrawGradientLine($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'];
|
||||
|
||||
// Récup des données
|
||||
$data = blockchain::getTransactionData($the_block, $type);
|
||||
$n_data = count($data);
|
||||
|
||||
|
||||
$vColor = array();
|
||||
|
||||
// Gestion de la transparence
|
||||
$alpha = 125;
|
||||
if ($mode < 4.5) $alpha = 0;
|
||||
if ($mode == 3.5) $alpha = 100;
|
||||
|
||||
// On choisit des couleurs au hasard
|
||||
$hex_val = array(
|
||||
ColorGradient::rgb2hex([rand(0,255),rand(0,255),rand(0,255)]),
|
||||
ColorGradient::rgb2hex([rand(0,255),rand(0,255),rand(0,255)]),
|
||||
ColorGradient::rgb2hex([rand(0,255),rand(0,255),rand(0,255)])
|
||||
);
|
||||
// Dégradé de couleurs entre bgcolor et blanc
|
||||
$hex_val = array(
|
||||
ColorGradient::rgb2hex([0,0,0]),
|
||||
ColorGradient::rgb2hex($vFgRGB)
|
||||
);
|
||||
|
||||
$gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], TX_HASH_LEN);
|
||||
for($i=0;$i<TX_HASH_LEN;$i++)
|
||||
{
|
||||
$rgbval = ColorGradient::hex2rgb($gradient[$i]);
|
||||
$vColor[$i] = new ColorGradient();
|
||||
$vColor[$i]->pct = ($i*1.0) / TX_HASH_LEN;
|
||||
$vColor[$i]->color = imagecolorallocatealpha($vImage, $rgbval[0], $rgbval[1], $rgbval[2], $alpha);
|
||||
}
|
||||
|
||||
// Une chance sur deux d'inverser entre fg et bg
|
||||
if (rand(0,100) < 50) {
|
||||
$fond = $vBgColor;
|
||||
$couleur = $vFgColor;
|
||||
} else {
|
||||
$fond = $vFgColor;
|
||||
$couleur = $vBgColor;
|
||||
}
|
||||
|
||||
// Remplir le fond
|
||||
imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond);
|
||||
|
||||
|
||||
// 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, $couleur);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
class topisto_line
|
||||
{
|
||||
public static 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'];
|
||||
|
||||
// Une chance sur deux d'inverser entre fg et bg
|
||||
if (rand(0,100) < 50) {
|
||||
$fond = $vBgColor;
|
||||
$couleur = $vFgColor;
|
||||
} else {
|
||||
$fond = $vFgColor;
|
||||
$couleur = $vBgColor;
|
||||
}
|
||||
|
||||
// Remplir le fond
|
||||
imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond);
|
||||
|
||||
// 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, $couleur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
// ---
|
||||
// --- Listening to blockchain.info to get the last block
|
||||
// ---
|
||||
|
||||
// ---
|
||||
// --- 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 'inc/draw.php';
|
||||
|
||||
// ---
|
||||
// --- Par défaut on cherche le dernier block
|
||||
// ---
|
||||
$block_hash = 'LAST';
|
||||
|
||||
// ---
|
||||
// --- Le cas échéant, on cherche block passé en argument
|
||||
// ---
|
||||
if (isset($argv[1])) $block_hash = $argv[1];
|
||||
|
||||
$mode=8;
|
||||
if (isset($argv[2])) $mode=intval($argv[2]);
|
||||
|
||||
$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;
|
||||
$height = GRAPH_HEIGHT;
|
||||
|
||||
// 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);
|
||||
|
||||
$type=2;
|
||||
if (count($the_block->tx)==1) $type = 4;
|
||||
|
||||
$paramHeader = blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
|
||||
|
||||
$parametres = [];
|
||||
$parametres['x'] = 0;
|
||||
$parametres['y'] = $bandeau;
|
||||
$parametres['width'] = $width;
|
||||
$parametres['height'] = $height;
|
||||
$parametres['methode'] = 5;
|
||||
$parametres['type'] = $type;
|
||||
$parametres['iterations'] = 200;
|
||||
$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];
|
||||
|
||||
topisto_line::DrawBlock($the_block, $img, $parametres);
|
||||
|
||||
imagepng($img, DATA_PATH.'/last/'.$the_block->hash.'.png');
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
?>
|
||||
@@ -1,36 +0,0 @@
|
||||
#!/bin/bash
|
||||
METHODE=line
|
||||
flag=$TMP_PATH/${METHODE}_bot.flag
|
||||
date=`date +%Y%m%d0000`
|
||||
|
||||
if [ -f $flag ];
|
||||
then
|
||||
echo "$METHODE_bot is already running !"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
touch $flag
|
||||
|
||||
cd $APPS_PATH/methode/$METHODE
|
||||
for BLOCK in `awk '{print $2}' $DATA_PATH/block_list.txt`
|
||||
do
|
||||
if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ]
|
||||
then
|
||||
php robot.php $BLOCK $(( RANDOM % 6))
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
done
|
||||
|
||||
rm -f $flag
|
||||
@@ -265,8 +265,6 @@ class CubicSplines
|
||||
}
|
||||
}
|
||||
|
||||
define('TX_HASH_LEN',64);
|
||||
|
||||
class topisto_spline
|
||||
{
|
||||
public static function DefaultDrawBlock($the_block, $vImage, $x, $y, $graph_width, $graph_height, $type=1)
|
||||
|
||||
@@ -21,9 +21,6 @@ class topisto_spline2
|
||||
//
|
||||
public static function DrawBlock($the_block, $vImage, $parametres)
|
||||
{
|
||||
|
||||
return topisto_spline2::DrawLine($the_block, $vImage, $parametres);
|
||||
|
||||
$somme = 0;
|
||||
$min =-1;
|
||||
$max = 0;
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
<?php
|
||||
|
||||
use codeagent\treemap\Treemap;
|
||||
use codeagent\treemap\presenter\ImagePresenter;
|
||||
use codeagent\treemap\presenter\NodeInfo;
|
||||
use codeagent\treemap\Gradient;
|
||||
|
||||
// ---
|
||||
// --- Local fonctions
|
||||
// ---
|
||||
function rgb2hex($rgb) {
|
||||
$hex = "#";
|
||||
$hex .= str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT);
|
||||
$hex .= str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT);
|
||||
$hex .= str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT);
|
||||
|
||||
return $hex; // returns the hex value including the number sign (#)
|
||||
}
|
||||
|
||||
function hex2rgb($color){
|
||||
$color = str_replace('#', '', $color);
|
||||
if (strlen($color) != 6){ return array(0,0,0); }
|
||||
$rgb = array();
|
||||
for ($x=0;$x<3;$x++){
|
||||
$rgb[$x] = hexdec(substr($color,(2*$x),2));
|
||||
}
|
||||
return $rgb;
|
||||
}
|
||||
|
||||
class topisto_treemap
|
||||
{
|
||||
private static function getRGB($methode, $gradient, $factor)
|
||||
{
|
||||
switch($methode)
|
||||
{
|
||||
case 0:
|
||||
$rgb = [rand(0,255),rand(0,255),rand(0,255)];
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$rgb = [80,80,80];
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$factor=rand(0,100);
|
||||
$rgb = [255,255,255];
|
||||
if ($factor < 50 ) $rgb = [255,0,0];
|
||||
if ($factor < 25 ) $rgb = [0,0,255];
|
||||
if ($factor < 10 ) $rgb = [255,255,0];
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$rgb = hex2rgb($gradient[1]->color($factor));
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$rgb = hex2rgb($gradient[2]->color($factor));
|
||||
break;
|
||||
|
||||
case 999:
|
||||
$rgb = hex2rgb($gradient[3]->color($factor));
|
||||
break;
|
||||
|
||||
default:
|
||||
$rgb = hex2rgb($gradient[0]->color($factor));
|
||||
}
|
||||
|
||||
return $rgb;
|
||||
}
|
||||
|
||||
public static 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);
|
||||
|
||||
imagerectangle($vImage, $x1, $y1, $x2, $y2, $vBgColor);
|
||||
}
|
||||
|
||||
imagerectangle($vImage, $x, $y, $x+$width-1, $y+$height, $vBgColor);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
// ---
|
||||
// --- Listening to blockchain.info to get the last block
|
||||
// ---
|
||||
|
||||
// ---
|
||||
// --- La config globale
|
||||
// ---
|
||||
require_once '../../global/inc/config.php';
|
||||
|
||||
// ---
|
||||
// --- External dependances
|
||||
// ---
|
||||
require TOPISTO_PATH.'/ressources/vendor/autoload.php';
|
||||
|
||||
// ---
|
||||
// --- Internal dependances
|
||||
// ---
|
||||
require_once APP_PATH.'/blockchain/inc/block.php';
|
||||
require_once 'inc/treemap.php';
|
||||
|
||||
// ---
|
||||
// --- Par défaut on cherche le dernier block
|
||||
// ---
|
||||
$block_hash = 'LAST';
|
||||
|
||||
// ---
|
||||
// --- Le cas échéant, on cherche block passé en argument
|
||||
// ---
|
||||
if (isset($argv[1])) $block_hash = $argv[1];
|
||||
|
||||
$mode=rand(0, 5);
|
||||
if (isset($argv[2])) $mode=intval($argv[2]);
|
||||
|
||||
$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;
|
||||
$height = GRAPH_HEIGHT;
|
||||
|
||||
// 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);
|
||||
|
||||
$type=2;
|
||||
if (count($the_block->tx)==1) $type=4;
|
||||
|
||||
$param0 = blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
|
||||
|
||||
$parametres = [];
|
||||
$parametres['x'] = 0;
|
||||
$parametres['y'] = $bandeau;
|
||||
$parametres['width'] = $width;
|
||||
$parametres['height'] = $height;
|
||||
$parametres['methode'] = $mode;
|
||||
$parametres['type'] = $type;
|
||||
$parametres['transparent_color'] = $param0[0];
|
||||
$parametres['background_color'] = $param0[1];
|
||||
$parametres['font_color'] = $param0[2];
|
||||
$parametres['fontname'] = $param0[3];
|
||||
|
||||
topisto_treemap::DrawBlock($the_block, $img, $parametres);
|
||||
|
||||
imagepng($img, DATA_PATH.'/treemapV2/'.$the_block->hash.'.png');
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
?>
|
||||
@@ -1,32 +0,0 @@
|
||||
#!/bin/bash
|
||||
flag=$TMP_PATH/treemapV2_bot.flag
|
||||
date=`date +%Y%m%d0000`
|
||||
|
||||
if [ -f $flag ];
|
||||
then
|
||||
echo "treemap_bot is already running !"
|
||||
exit 0
|
||||
fi
|
||||
touch $flag
|
||||
|
||||
cd $APPS_PATH/methode/treemapV2
|
||||
for BLOCK in `awk '{print $2}' $DATA_PATH/block_list.txt`
|
||||
do
|
||||
if [ ! -f $DATA_PATH/treemapV2/$BLOCK.png ]
|
||||
then
|
||||
php robot.php $BLOCK $((RANDOM % 6))
|
||||
fi
|
||||
|
||||
BNAME=`grep $BLOCK $DATA_PATH/block_list.txt | awk '{print $1}'`
|
||||
if [ "$BNAME" == "LAST" ]
|
||||
then
|
||||
touch $DATA_PATH/treemapV2/$BLOCK.png
|
||||
else
|
||||
touch -t $date $DATA_PATH/treemapV2/$BLOCK.png
|
||||
fi
|
||||
|
||||
rm -f $DATA_PATH/hasard/$BLOCK.png
|
||||
ln $DATA_PATH/treemapV2/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
|
||||
done
|
||||
|
||||
rm -f $flag
|
||||
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
|
||||
use codeagent\treemap\Treemap;
|
||||
use codeagent\treemap\presenter\ImagePresenter;
|
||||
use codeagent\treemap\presenter\NodeInfo;
|
||||
use codeagent\treemap\Gradient;
|
||||
|
||||
function rgb2hex($rgb)
|
||||
{
|
||||
return "#0203FF";
|
||||
}
|
||||
|
||||
class topisto_veraMolnar
|
||||
{
|
||||
public static 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
// ---
|
||||
// --- Listening to blockchain.info to get the last block
|
||||
// ---
|
||||
|
||||
// ---
|
||||
// --- La config globale
|
||||
// ---
|
||||
require_once '../../global/inc/config.php';
|
||||
|
||||
// ---
|
||||
// --- External dependances
|
||||
// ---
|
||||
require TOPISTO_PATH.'/ressources/vendor/autoload.php';
|
||||
|
||||
// ---
|
||||
// --- Internal dependances
|
||||
// ---
|
||||
require_once APP_PATH.'/blockchain/inc/block.php';
|
||||
require_once 'inc/treemap.php';
|
||||
|
||||
// ---
|
||||
// --- Par défaut on cherche le dernier block
|
||||
// ---
|
||||
$block_hash = 'LAST';
|
||||
|
||||
// ---
|
||||
// --- Le cas échéant, on cherche block passé en argument
|
||||
// ---
|
||||
if (isset($argv[1])) $block_hash = $argv[1];
|
||||
|
||||
$mode=8;
|
||||
if (isset($argv[2])) $mode=intval($argv[2]);
|
||||
|
||||
$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;
|
||||
$height = GRAPH_HEIGHT;
|
||||
|
||||
// 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);
|
||||
|
||||
$type=2;
|
||||
if (count($the_block->tx)==1) $type = 4;
|
||||
|
||||
$param0 = blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
|
||||
|
||||
$parametres = [];
|
||||
$parametres['x'] = 0;
|
||||
$parametres['y'] = $bandeau;
|
||||
$parametres['width'] = $width;
|
||||
$parametres['height'] = $height;
|
||||
$parametres['methode'] = $mode;
|
||||
$parametres['type'] = $type;
|
||||
$parametres['transparent_color'] = $param0[0];
|
||||
$parametres['background_color'] = $param0[1];
|
||||
$parametres['font_color'] = $param0[2];
|
||||
$parametres['fontname'] = $param0[3];
|
||||
$parametres['font_RGB'] = $param0[4];
|
||||
$parametres['background_RGB'] = $param0[5];
|
||||
|
||||
topisto_veraMolnar::DrawBlock($the_block, $img, $parametres);
|
||||
|
||||
imagepng($img, DATA_PATH.'/veraMolnar/'.$the_block->hash.'.png');
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
?>
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
flag=$TMP_PATH/veraMolnar_bot.flag
|
||||
date=`date +%Y%m%d0000`
|
||||
|
||||
if [ -f $flag ];
|
||||
then
|
||||
echo "veraMolnar_bot is already running !"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
touch $flag
|
||||
|
||||
cd $APPS_PATH/methode/veraMolnar
|
||||
for BLOCK in `awk '{print $2}' $DATA_PATH/block_list.txt`
|
||||
do
|
||||
if [ ! -f $DATA_PATH/veraMolnar/$BLOCK.png ]
|
||||
then
|
||||
php robot.php $BLOCK $(( RANDOM % 6))
|
||||
fi
|
||||
|
||||
BNAME=`grep $BLOCK $DATA_PATH/block_list.txt | awk '{print $1}'`
|
||||
if [ "$BNAME" == "LAST" ]
|
||||
then
|
||||
touch $DATA_PATH/veraMolnar/$BLOCK.png
|
||||
else
|
||||
touch -t $date $DATA_PATH/veraMolnar/$BLOCK.png
|
||||
fi
|
||||
|
||||
rm -f $DATA_PATH/hasard/$BLOCK.png
|
||||
ln $DATA_PATH/veraMolnar/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
|
||||
done
|
||||
|
||||
rm -f $flag
|
||||
86
methode2/line/draw.php
Normal file
86
methode2/line/draw.php
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
106
methode2/linegradient/draw.php
Normal file
106
methode2/linegradient/draw.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
119
methode2/linehashed/draw.php
Normal file
119
methode2/linehashed/draw.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
119
methode2/linehashedtx/draw.php
Normal file
119
methode2/linehashedtx/draw.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
89
methode2/mondrian/draw.php
Normal file
89
methode2/mondrian/draw.php
Normal 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
156
methode2/peigne/draw.php
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
181
methode2/peignealpha/draw.php
Normal file
181
methode2/peignealpha/draw.php
Normal 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
118
methode2/robot.php
Normal 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
52
methode2/robot.sh
Executable 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
|
||||
156
methode2/splinelinegradient/draw.php
Normal file
156
methode2/splinelinegradient/draw.php
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
181
methode2/splinelinegradientalpha/draw.php
Normal file
181
methode2/splinelinegradientalpha/draw.php
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
55
methode2/treemap2/draw.php
Normal file
55
methode2/treemap2/draw.php
Normal 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);
|
||||
}
|
||||
|
||||
?>
|
||||
95
methode2/veraMolnar/draw.php
Normal file
95
methode2/veraMolnar/draw.php
Normal 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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
2
robot.sh
2
robot.sh
@@ -24,7 +24,7 @@ $APPS_PATH/scripts/hashes.sh
|
||||
#
|
||||
# Draw the BLOCKS
|
||||
#
|
||||
$APPS_PATH/scripts/blocks.sh
|
||||
$APPS_PATH/scripts/blocks2.sh
|
||||
|
||||
#
|
||||
# Send a TWEET
|
||||
|
||||
@@ -53,6 +53,16 @@ then
|
||||
echec
|
||||
fi
|
||||
|
||||
#
|
||||
# CHOISIR UNE METHODE2 AU HASARD
|
||||
#
|
||||
ROBOT=`ls $APPS_PATH/methode2 | shuf | tail -n 1`
|
||||
debug $ROBOT
|
||||
|
||||
$APPS_PATH/methode2/robot.sh $ROBOT
|
||||
|
||||
succes
|
||||
|
||||
#
|
||||
# CHOISIR UNE METHODE AU HASARD
|
||||
#
|
||||
|
||||
91
scripts/blocks2.sh
Executable file
91
scripts/blocks2.sh
Executable file
@@ -0,0 +1,91 @@
|
||||
#!/bin/bash
|
||||
lescript=`basename $0 .sh`
|
||||
|
||||
#
|
||||
# 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
|
||||
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
|
||||
|
||||
#
|
||||
# CHOISIR UNE METHODE2 AU HASARD
|
||||
#
|
||||
for METHODE in `ls $APPS_PATH/methode2 | grep -v robot | shuf`
|
||||
do
|
||||
echo $METHODE
|
||||
if [ ! -d $DATA_PATH/$METHODE ]
|
||||
then
|
||||
mkdir -p $DATA_PATH/$METHODE
|
||||
fi
|
||||
|
||||
if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ]
|
||||
then
|
||||
cd $APPS_PATH/methode2
|
||||
php robot.php $METHODE $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
|
||||
done
|
||||
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
|
||||
@@ -6,6 +6,8 @@ then
|
||||
then
|
||||
find $DATA_PATH -mtime +1 -type f -name *.png -exec rm -f {} \;
|
||||
find $DATA_PATH -mtime +1 -type f -name *.zip -exec rm -f {} \;
|
||||
|
||||
find $TMP_PATH -mtime +3 -type f -name *.flag -exec rm -f {} \;
|
||||
fi
|
||||
else
|
||||
if [ "$1" -eq "FULL" ]
|
||||
|
||||
@@ -53,12 +53,14 @@ then
|
||||
echec
|
||||
fi
|
||||
|
||||
#
|
||||
# Toujours placer la version HASHES
|
||||
#
|
||||
debug "Compute HASHES ..."
|
||||
$APPS_PATH/methode/hashes/robot.sh
|
||||
|
||||
#
|
||||
debug "Compute HASHES2HASHES ..."
|
||||
$APPS_PATH/methode/hashes2hashes/robot.sh
|
||||
|
||||
#
|
||||
# SORTIE AVEC SUCCES
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user