first commit
This commit is contained in:
111
methode/full_spline/big_one.php
Normal file
111
methode/full_spline/big_one.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?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 APP_PATH.'/spline/inc/splines.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 ='';
|
||||
|
||||
$mode = 0;
|
||||
$iterations = 1;
|
||||
|
||||
$bandeau = 50;
|
||||
$marge = 25;
|
||||
$text_border = 20;
|
||||
$width = GRAPH_WIDTH*8;
|
||||
$height = GRAPH_HEIGHT*8;
|
||||
|
||||
$img_w = $marge + ($width*2) + (2*$text_border);
|
||||
$img_h = $marge + ($height*2) + (2*$bandeau);
|
||||
|
||||
// création d'une image plus haute pour inclure bandeaux haut et bas
|
||||
$img = imagecreatetruecolor( $img_w, $img_h);
|
||||
|
||||
//
|
||||
// Les 4 parties du block : inputs, outputs, fees, reward
|
||||
//
|
||||
$mode=5;
|
||||
$iterations=50;
|
||||
|
||||
$type=2;
|
||||
$x0 = $text_border; $y0 = $bandeau;
|
||||
topisto_spline::DefaultDrawBlock($the_block, $img, $x0, $y0, $width, $height, $type);
|
||||
|
||||
$type=1;
|
||||
$x0 = $text_border+$marge+$width; $y0 = $bandeau;
|
||||
topisto_spline::DefaultDrawBlock($the_block, $img, $x0, $y0, $width, $height, $type);
|
||||
|
||||
$type=3;
|
||||
$x0 = $text_border; $y0 = $marge+$height+$bandeau;
|
||||
topisto_spline::DefaultDrawBlock($the_block, $img, $x0, $y0, $width, $height, $type);
|
||||
|
||||
$type=4;
|
||||
$x0 = $text_border+$marge+$width; $y0 = $marge+$height+$bandeau;
|
||||
topisto_spline::DefaultDrawBlock($the_block, $img, $x0, $y0, $width, $height, $type);
|
||||
|
||||
blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
|
||||
|
||||
$fond = imagecolorallocate($img, 40, 40, 40);
|
||||
imagefilledrectangle($img, 0, $bandeau, $text_border, $img_h-$bandeau, $fond);
|
||||
imagefilledrectangle($img, $img_w-$text_border, $bandeau, $img_w, $img_h-$bandeau, $fond);
|
||||
imagefilledrectangle($img, $text_border+$width, $bandeau, $text_border+$marge+$width, $img_h-$bandeau, $fond);
|
||||
imagefilledrectangle($img, 0, $bandeau+$height, $img_w - $text_border, $bandeau+$marge+$height, $fond);
|
||||
|
||||
// Les textes
|
||||
putenv('GDFONTPATH='.RESS_PATH.'/fonts/');
|
||||
$font = 'DS-DIGIB.TTF';
|
||||
|
||||
$fontColor = imagecolorallocate($img, 158,227,253);
|
||||
$the_texte = "Height : ".$the_block->height;
|
||||
imagettftext($img,18, 0, 5, $bandeau-5, $fontColor, $font, $the_texte);
|
||||
$the_texte = "Inputs : ".$the_block->topisto_inputs;
|
||||
imagettftext($img,15, 90, $text_border-3, $bandeau+$height, $fontColor, $font, $the_texte);
|
||||
$the_texte = "Outputs : ".$the_block->topisto_outputs;
|
||||
imagettftext($img,15, 90, $text_border+$width+$marge-3, $bandeau+$height, $fontColor, $font, $the_texte);
|
||||
$the_texte = "Fees : ".$the_block->topisto_fees;
|
||||
imagettftext($img,15, 90, $text_border-3, $bandeau+(2*$height)+$marge-3, $fontColor, $font, $the_texte);
|
||||
$the_texte = "Reward : ".$the_block->topisto_reward;
|
||||
imagettftext($img,15, 90, $text_border+$width+$marge-3, $bandeau+(2*$height)+$marge-3, $fontColor, $font, $the_texte);
|
||||
|
||||
if ($the_name == '') $the_name = date('Ymd H:m:s', $the_block->time);
|
||||
$bbox = imagettfbbox(14, 0, $font, $the_name);
|
||||
imagettftext($img, 14, 0, ($img_w-3)-($bbox[2]-$bbox[0]), ($bandeau-5), $fontColor, $font, $the_name);
|
||||
|
||||
imagepng($img, BIG_PATH.'/full_spline/'.$the_block->hash.'.png');
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
?>
|
||||
100
methode/full_spline/robot.php
Normal file
100
methode/full_spline/robot.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?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 APP_PATH.'/methode/spline/inc/splines.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 ='';
|
||||
|
||||
$mode = 0;
|
||||
$iterations = 1;
|
||||
|
||||
$bandeau = 50;
|
||||
$marge = 25;
|
||||
$text_border = 20;
|
||||
$width = GRAPH_WIDTH;
|
||||
$height = GRAPH_HEIGHT;
|
||||
|
||||
$img_w = $marge + ($width*2) + (2*$text_border);
|
||||
$img_h = $marge + ($height*2) + (2*$bandeau);
|
||||
|
||||
// création d'une image plus haute pour inclure bandeaux haut et bas
|
||||
$img = imagecreatetruecolor( $img_w, $img_h);
|
||||
|
||||
$param_header = blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
|
||||
$tr_color = $param_header[0];
|
||||
$fond = $param_header[1];
|
||||
$font = $param_header[3];
|
||||
$fontColor = $param_header[2];
|
||||
|
||||
//
|
||||
// Les 4 parties du block : inputs, outputs, fees, reward
|
||||
//
|
||||
$mode=5;
|
||||
$iterations=50;
|
||||
|
||||
$type=1;
|
||||
$x0 = $text_border; $y0 = $bandeau;
|
||||
topisto_spline::DefaultDrawBlock($the_block, $img, $x0, $y0, $bandeau + $width*2, $height, $type);
|
||||
|
||||
$type=3;
|
||||
$x0 = $text_border; $y0 = $marge+$height+$bandeau;
|
||||
topisto_spline::DefaultDrawBlock($the_block, $img, $x0, $y0, $width, $height, $type);
|
||||
|
||||
$type=4;
|
||||
$x0 = $text_border+$marge+$width; $y0 = $marge+$height+$bandeau;
|
||||
topisto_spline::DefaultDrawBlock($the_block, $img, $x0, $y0, $width, $height, $type);
|
||||
|
||||
imagefilledrectangle($img, 0, $bandeau, $text_border, $img_h-$bandeau, $fond);
|
||||
imagefilledrectangle($img, $img_w-$text_border, $bandeau, $img_w, $img_h-$bandeau, $fond);
|
||||
imagefilledrectangle($img, $text_border+$width, $bandeau + $height, $text_border+$marge+$width, $img_h-$bandeau, $fond);
|
||||
imagefilledrectangle($img, 0, $bandeau+$height, $img_w - $text_border, $bandeau+$marge+$height, $fond);
|
||||
|
||||
// Les textes
|
||||
$the_texte = "Outputs : ".$the_block->topisto_inputs;
|
||||
imagettftext($img,15, 90, $text_border-3, $bandeau+$height, $fontColor, $font, $the_texte);
|
||||
|
||||
$the_texte = "Fees : ".$the_block->topisto_fees;
|
||||
imagettftext($img,15, 90, $text_border-3, $bandeau+(2*$height)+$marge-3, $fontColor, $font, $the_texte);
|
||||
|
||||
$the_texte = "Reward : ".$the_block->topisto_reward;
|
||||
imagettftext($img,15, 90, $text_border+$width+$marge-3, $bandeau+(2*$height)+$marge-3, $fontColor, $font, $the_texte);
|
||||
|
||||
imagepng($img, DATA_PATH.'/full_spline/'.$the_block->hash.'.png');
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
?>
|
||||
33
methode/full_spline/robot.sh
Executable file
33
methode/full_spline/robot.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
flag=$TMP_PATH/full_spline_bot.flag
|
||||
date=`date +%Y%m%d0000`
|
||||
|
||||
if [ -f $flag ];
|
||||
then
|
||||
echo "full_spline_bot is already running !"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
touch $flag
|
||||
|
||||
cd $APPS_PATH/methode/full_spline
|
||||
for BLOCK in `awk '{print $2}' $DATA_PATH/block_list.txt`
|
||||
do
|
||||
if [ ! -f $DATA_PATH/full_spline/$BLOCK.png ]
|
||||
then
|
||||
php robot.php $BLOCK
|
||||
fi
|
||||
|
||||
BNAME=`grep $BLOCK $DATA_PATH/block_list.txt | awk '{print $1}'`
|
||||
if [ "$BNAME" == "LAST" ]
|
||||
then
|
||||
touch $DATA_PATH/full_spline/$BLOCK.png
|
||||
else
|
||||
touch -t $date $DATA_PATH/full_spline/$BLOCK.png
|
||||
fi
|
||||
|
||||
rm -f $DATA_PATH/hasard/$BLOCK.png
|
||||
ln $DATA_PATH/full_spline/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
|
||||
done
|
||||
|
||||
rm -f $flag
|
||||
84
methode/full_treemap/robot.php
Normal file
84
methode/full_treemap/robot.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?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 APP_PATH.'/methode/treemap/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;
|
||||
|
||||
$img_w = $marge + ($width*2) + (2*$text_border);
|
||||
$img_h = $marge + ($height*2) + (2*$bandeau);
|
||||
|
||||
// création d'une image plus haute pour inclure bandeaux haut et bas
|
||||
$img = imagecreatetruecolor( $img_w, $img_h);
|
||||
|
||||
$param_header = blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
|
||||
$tr_color = $param_header[0];
|
||||
$fond = $param_header[1];
|
||||
$font = $param_header[3];
|
||||
$fontColor = $param_header[2];
|
||||
|
||||
// Les parties du block : outputs, fees, reward
|
||||
topisto_treemap::DrawBlock($the_block, $img, $text_border+0, $bandeau,$marge+($width*2), $height, $mode, 1);
|
||||
topisto_treemap::DrawBlock($the_block, $img, $text_border+0, $marge+$height + $bandeau, $width, $height, $mode, 3);
|
||||
topisto_treemap::DrawBlock($the_block, $img, $text_border+$marge+$width, $marge+$height + $bandeau, $width, $height, $mode, 4);
|
||||
|
||||
imagefilledrectangle($img, 0, $bandeau, $text_border, $img_h-$bandeau, $fond);
|
||||
imagefilledrectangle($img, $img_w-$text_border, $bandeau, $img_w, $img_h-$bandeau, $fond);
|
||||
imagefilledrectangle($img, $text_border+$width, $bandeau + $height, $text_border+$marge+$width, $img_h-$bandeau, $fond);
|
||||
imagefilledrectangle($img, 0, $bandeau+$height, $img_w - $text_border, $bandeau+$marge+$height, $fond);
|
||||
|
||||
// Les textes
|
||||
$the_texte = "Outputs : ".$the_block->topisto_inputs;
|
||||
imagettftext($img,15, 90, $text_border-3, $bandeau+$height, $fontColor, $font, $the_texte);
|
||||
|
||||
$the_texte = "Fees : ".$the_block->topisto_fees;
|
||||
imagettftext($img,15, 90, $text_border-3, $bandeau+(2*$height)+$marge-3, $fontColor, $font, $the_texte);
|
||||
|
||||
$the_texte = "Reward : ".$the_block->topisto_reward;
|
||||
imagettftext($img,15, 90, $text_border+$width+$marge-3, $bandeau+(2*$height)+$marge-3, $fontColor, $font, $the_texte);
|
||||
|
||||
imagepng($img, DATA_PATH.'/full_treemap/'.$the_block->hash.'.png');
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
?>
|
||||
33
methode/full_treemap/robot.sh
Executable file
33
methode/full_treemap/robot.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
flag=$TMP_PATH/full_treemap_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/full_treemap
|
||||
for BLOCK in `awk '{print $2}' $DATA_PATH/block_list.txt`
|
||||
do
|
||||
|
||||
if [ ! -f $DATA_PATH/full_treemap/$BLOCK-$MODE.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/full_treemap/$BLOCK.png
|
||||
else
|
||||
touch -t $date $DATA_PATH/full_treemap/$BLOCK.png
|
||||
fi
|
||||
|
||||
rm -f $DATA_PATH/hasard/$BLOCK.png
|
||||
ln $DATA_PATH/full_treemap/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
|
||||
done
|
||||
|
||||
rm -f $flag
|
||||
82
methode/full_treemap_fuzzy/robot.php
Normal file
82
methode/full_treemap_fuzzy/robot.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?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 APP_PATH.'/methode/treemap_fuzzy/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;
|
||||
|
||||
$img_w = $marge + ($width*2) + (2*$text_border);
|
||||
$img_h = $marge + ($height*2) + (2*$bandeau);
|
||||
|
||||
// création d'une image plus haute pour inclure bandeaux haut et bas
|
||||
$img = imagecreatetruecolor( $img_w, $img_h);
|
||||
|
||||
$param_header = blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
|
||||
$tr_color = $param_header[0];
|
||||
$fond = $param_header[1];
|
||||
$font = $param_header[3];
|
||||
$fontColor = $param_header[2];
|
||||
|
||||
// Les parties du block : outputs, fees, reward
|
||||
topisto_treemap_fuzzy::DrawBlock($the_block, $img, $text_border+0, $bandeau,$marge+($width*2), $height, $mode, 1);
|
||||
topisto_treemap_fuzzy::DrawBlock($the_block, $img, $text_border+0, $marge+$height + $bandeau, $width, $height, $mode, 3);
|
||||
topisto_treemap_fuzzy::DrawBlock($the_block, $img, $text_border+$marge+$width, $marge+$height + $bandeau, $width, $height, $mode, 4);
|
||||
|
||||
imagefilledrectangle($img, 0, $bandeau, $text_border, $img_h-$bandeau, $fond);
|
||||
imagefilledrectangle($img, $img_w-$text_border, $bandeau, $img_w, $img_h-$bandeau, $fond);
|
||||
imagefilledrectangle($img, $text_border+$width, $bandeau + $height, $text_border+$marge+$width, $img_h-$bandeau, $fond);
|
||||
imagefilledrectangle($img, 0, $bandeau+$height, $img_w - $text_border, $bandeau+$marge+$height, $fond);
|
||||
|
||||
// Les textes
|
||||
$the_texte = "Outputs : ".$the_block->topisto_inputs;
|
||||
imagettftext($img,15, 90, $text_border-3, $bandeau+$height, $fontColor, $font, $the_texte);
|
||||
$the_texte = "Fees : ".$the_block->topisto_fees;
|
||||
imagettftext($img,15, 90, $text_border-3, $bandeau+(2*$height)+$marge-3, $fontColor, $font, $the_texte);
|
||||
$the_texte = "Reward : ".$the_block->topisto_reward;
|
||||
imagettftext($img,15, 90, $text_border+$width+$marge-3, $bandeau+(2*$height)+$marge-3, $fontColor, $font, $the_texte);
|
||||
|
||||
imagepng($img, DATA_PATH.'/full_treemap_fuzzy/'.$the_block->hash.'.png');
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
?>
|
||||
32
methode/full_treemap_fuzzy/robot.sh
Executable file
32
methode/full_treemap_fuzzy/robot.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
flag=$TMP_PATH/full_treemap_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/full_treemap_fuzzy
|
||||
for BLOCK in `awk '{print $2}' $DATA_PATH/block_list.txt`
|
||||
do
|
||||
if [ ! -f $DATA_PATH/full_treemap_fuzzy/$BLOCK.png ]
|
||||
then
|
||||
php robot.php $BLOCK
|
||||
fi
|
||||
|
||||
BNAME=`grep $BLOCK $DATA_PATH/block_list.txt | awk '{print $1}'`
|
||||
if [ "$BNAME" == "LAST" ]
|
||||
then
|
||||
touch $DATA_PATH/full_treemap_fuzzy/$BLOCK.png
|
||||
else
|
||||
touch -t $date $DATA_PATH/full_treemap_fuzzy/$BLOCK.png
|
||||
fi
|
||||
|
||||
rm -f $DATA_PATH/hasard/$BLOCK.png
|
||||
ln $DATA_PATH/full_treemap_fuzzy/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
|
||||
done
|
||||
|
||||
rm -f $flag
|
||||
57
methode/hashes/assemble.php
Normal file
57
methode/hashes/assemble.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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';
|
||||
|
||||
$width = 840;
|
||||
$height = 104;
|
||||
$h = $height*6;
|
||||
$final_hash = 'default';
|
||||
|
||||
$img = imagecreatetruecolor($width, $h);
|
||||
|
||||
$tr = imagecolorallocate($img, 220, 220, 220);
|
||||
imagecolortransparent($img, $tr);
|
||||
imagefilledrectangle($img, 0, 0, $width, $height*6, $tr);
|
||||
|
||||
$handle = fopen(DATA_PATH.'/hashes2hashes/liste.txt', 'r');
|
||||
if ($handle) {
|
||||
while (($hash = fgets($handle, 4096)) !== false) {
|
||||
$hash = preg_replace('~[[:cntrl:]]~', '', $hash);
|
||||
$split = explode(' ', $hash);
|
||||
$hash = $split[1];
|
||||
if ($final_hash == 'default') $final_hash = $hash;
|
||||
$hash = DATA_PATH.'/hashes/'.$hash.'.png';
|
||||
if (file_exists($hash))
|
||||
{
|
||||
$h -= $height;
|
||||
$src_img = imagecreatefrompng($hash);
|
||||
if ($src_img)
|
||||
{
|
||||
if (FALSE === imagecopy($img, $src_img, 0, $h, 0, 0, $width, $height))
|
||||
echo "Erreur : problème de copie image".PHP_EOL;
|
||||
} else echo "Erreur: ".$hash." ne semble pas être une image PNG".PHP_EOL;
|
||||
} else echo "Erreur: ".$hash." n'a pas été trouvé".PHP_EOL;
|
||||
}
|
||||
if (!feof($handle)) {
|
||||
echo "Erreur: fgets() a échoué".PHP_EOL;
|
||||
}
|
||||
fclose($handle);
|
||||
} else echo "Erreur: fopen('".DATA_PATH."/hashes2hashes/liste.txt') a échoué".PHP_EOL;
|
||||
|
||||
imagepng($img, DATA_PATH.'/hashes2hashes/'.$final_hash.'.png');
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
?>
|
||||
60
methode/hashes/robot.php
Normal file
60
methode/hashes/robot.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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';
|
||||
|
||||
// ---
|
||||
// --- 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();
|
||||
|
||||
$bandeau = 50;
|
||||
$marge = 0;
|
||||
$text_border = 20;
|
||||
$width = GRAPH_WIDTH;
|
||||
$height = 2;
|
||||
|
||||
// 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);
|
||||
|
||||
blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
|
||||
|
||||
imagepng($img, DATA_PATH.'/hashes/'.$the_block->hash.'.png');
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
?>
|
||||
42
methode/hashes/robot.sh
Executable file
42
methode/hashes/robot.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
flag=$TMP_PATH/hashes_bot.flag
|
||||
date=`date +%Y%m%d0000`
|
||||
|
||||
if [ -f $flag ];
|
||||
then
|
||||
echo "hashes_bot is already running !"
|
||||
exit 0
|
||||
fi
|
||||
touch $flag
|
||||
|
||||
cd $APPS_PATH/methode/hashes
|
||||
for BLOCK in `grep LAST $DATA_PATH/block_list.txt | awk '{print $2}'`
|
||||
do
|
||||
if [ ! -f $DATA_PATH/hashes/$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
|
||||
else
|
||||
touch -t $date $DATA_PATH/hashes/$BLOCK.png
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
rm -f $flag
|
||||
63
methode/spline/big_one.php
Normal file
63
methode/spline/big_one.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
// ---
|
||||
// --- Listening to blockchain.info to get the last block
|
||||
// ---
|
||||
|
||||
// ---
|
||||
// --- La config globale
|
||||
// ---
|
||||
require_once '../global/inc/config.php';
|
||||
|
||||
// ---
|
||||
// --- Internal dependances
|
||||
// ---
|
||||
require_once APP_PATH.'/blockchain/inc/block.php';
|
||||
require_once 'inc/splines.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]);
|
||||
|
||||
$iterations = 1;
|
||||
if ($mode > 2) $iterations = 50;
|
||||
if (isset($_REQUEST['iterations'])) $iterations=intval($_REQUEST['iterations']);
|
||||
|
||||
$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;
|
||||
$width = GRAPH_WIDTH*8;
|
||||
$height = GRAPH_HEIGHT*8;
|
||||
|
||||
$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);
|
||||
|
||||
$x0=0; $y0=$bandeau;
|
||||
$type=2;
|
||||
if (count($the_block->tx) == 1) $type = 4;
|
||||
|
||||
blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
|
||||
|
||||
topisto_spline::DefaultDrawBlock($the_block, $img, $x0, $y0, $width, $height, $type);
|
||||
|
||||
imagepng($img, BIG_PATH.'/spline/'.$the_block->hash.'.png');
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
?>
|
||||
463
methode/spline/inc/splines.php
Normal file
463
methode/spline/inc/splines.php
Normal file
@@ -0,0 +1,463 @@
|
||||
<?php
|
||||
class ColorGradient
|
||||
{
|
||||
public $pct;
|
||||
public $color;
|
||||
|
||||
public static function RGB2HSV($R, $G, $B) // RGB values: 0-255, 0-255, 0-255
|
||||
{ // HSV values: 0-360, 0-100, 0-100
|
||||
// Convert the RGB byte-values to percentages
|
||||
$R = ($R / 255);
|
||||
$G = ($G / 255);
|
||||
$B = ($B / 255);
|
||||
|
||||
// Calculate a few basic values, the maximum value of R,G,B, the
|
||||
// minimum value, and the difference of the two (chroma).
|
||||
$maxRGB = max($R, $G, $B);
|
||||
$minRGB = min($R, $G, $B);
|
||||
$chroma = $maxRGB - $minRGB;
|
||||
|
||||
// Value (also called Brightness) is the easiest component to calculate,
|
||||
// and is simply the highest value among the R,G,B components.
|
||||
// We multiply by 100 to turn the decimal into a readable percent value.
|
||||
$computedV = 100 * $maxRGB;
|
||||
|
||||
// Special case if hueless (equal parts RGB make black, white, or grays)
|
||||
// Note that Hue is technically undefined when chroma is zero, as
|
||||
// attempting to calculate it would cause division by zero (see
|
||||
// below), so most applications simply substitute a Hue of zero.
|
||||
// Saturation will always be zero in this case, see below for details.
|
||||
if ($chroma == 0)
|
||||
return array(0, 0, $computedV);
|
||||
|
||||
// Saturation is also simple to compute, and is simply the chroma
|
||||
// over the Value (or Brightness)
|
||||
// Again, multiplied by 100 to get a percentage.
|
||||
$computedS = 100 * ($chroma / $maxRGB);
|
||||
|
||||
// Calculate Hue component
|
||||
// Hue is calculated on the "chromacity plane", which is represented
|
||||
// as a 2D hexagon, divided into six 60-degree sectors. We calculate
|
||||
// the bisecting angle as a value 0 <= x < 6, that represents which
|
||||
// portion of which sector the line falls on.
|
||||
if ($R == $minRGB)
|
||||
$h = 3 - (($G - $B) / $chroma);
|
||||
elseif ($B == $minRGB)
|
||||
$h = 1 - (($R - $G) / $chroma);
|
||||
else // $G == $minRGB
|
||||
$h = 5 - (($B - $R) / $chroma);
|
||||
|
||||
// After we have the sector position, we multiply it by the size of
|
||||
// each sector's arc (60 degrees) to obtain the angle in degrees.
|
||||
$computedH = 60 * $h;
|
||||
|
||||
return array($computedH, $computedS, $computedV);
|
||||
}
|
||||
|
||||
public static function HSV2RGB($h, $s, $v)
|
||||
{
|
||||
$s /= 256.0;
|
||||
if ($s == 0.0) return array($v,$v,$v);
|
||||
$h /= (256.0 / 6.0);
|
||||
$i = floor($h);
|
||||
$f = $h - $i;
|
||||
$p = (integer)($v * (1.0 - $s));
|
||||
$q = (integer)($v * (1.0 - $s * $f));
|
||||
$t = (integer)($v * (1.0 - $s * (1.0 - $f)));
|
||||
switch($i) {
|
||||
case 0: return array($v,$t,$p);
|
||||
case 1: return array($q,$v,$p);
|
||||
case 2: return array($p,$v,$t);
|
||||
case 3: return array($p,$q,$v);
|
||||
case 4: return array($t,$p,$v);
|
||||
default: return array($v,$p,$q);
|
||||
}
|
||||
}
|
||||
|
||||
public static function gradient($from_color, $to_color, $graduations = 10)
|
||||
{
|
||||
$graduations--;
|
||||
$startcol = str_replace("#", "", $from_color);
|
||||
$endcol = str_replace("#", "", $to_color);
|
||||
$RedOrigin = hexdec(substr($startcol, 0, 2));
|
||||
$GrnOrigin = hexdec(substr($startcol, 2, 2));
|
||||
$BluOrigin = hexdec(substr($startcol, 4, 2));
|
||||
if ($graduations >= 2) { // for at least 3 colors
|
||||
$GradientSizeRed = (hexdec(substr($endcol, 0, 2)) - $RedOrigin) / $graduations; //Graduation Size Red
|
||||
$GradientSizeGrn = (hexdec(substr($endcol, 2, 2)) - $GrnOrigin) / $graduations;
|
||||
$GradientSizeBlu = (hexdec(substr($endcol, 4, 2)) - $BluOrigin) / $graduations;
|
||||
for ($i = 0; $i <= $graduations; $i++) {
|
||||
$RetVal[$i] = strtoupper("#" . str_pad(dechex($RedOrigin + ($GradientSizeRed * $i)), 2, '0', STR_PAD_LEFT) .
|
||||
str_pad(dechex($GrnOrigin + ($GradientSizeGrn * $i)), 2, '0', STR_PAD_LEFT) .
|
||||
str_pad(dechex($BluOrigin + ($GradientSizeBlu * $i)), 2, '0', STR_PAD_LEFT));
|
||||
}
|
||||
} elseif ($graduations == 1) { // exactlly 2 colors
|
||||
$RetVal[] = $from_color;
|
||||
$RetVal[] = $to_color;
|
||||
} else { // one color
|
||||
$RetVal[] = $from_color;
|
||||
}
|
||||
return $RetVal;
|
||||
}
|
||||
|
||||
public static function hex2rgb($hex) { return sscanf($hex, "#%02x%02x%02x"); }
|
||||
|
||||
// ---
|
||||
// --- Local fonctions
|
||||
// ---
|
||||
public static 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 (#)
|
||||
}
|
||||
}
|
||||
|
||||
class Plot
|
||||
{
|
||||
private $aCoords;
|
||||
function __construct(&$aCoords)
|
||||
{
|
||||
$this->aCoords = &$aCoords;
|
||||
}
|
||||
|
||||
public function drawLine($vImage, $vColor, $iPosX = 0, $imaxX = false)
|
||||
{
|
||||
$maxX = $imaxX;
|
||||
if ($imaxX === false) $maxX = imagesx($vImage);
|
||||
|
||||
reset($this->aCoords);
|
||||
list($iPrevX, $iPrevY) = each($this->aCoords);
|
||||
|
||||
while (list ($x, $y) = each($this->aCoords))
|
||||
{
|
||||
$laCouleur = null;
|
||||
if (!is_array($vColor)) $laCouleur = $vColor;
|
||||
else
|
||||
{
|
||||
$s = count($vColor) - 1;
|
||||
$laCouleur = $vColor[$s]->color;
|
||||
$pct = $x / $maxX;
|
||||
while(($s>0)&&($pct < $vColor[$s]->pct))
|
||||
{
|
||||
$s -= 1;
|
||||
$laCouleur = $vColor[$s]->color;
|
||||
}
|
||||
}
|
||||
imageline($vImage, round($iPrevX), round($iPrevY), round($x), round($y), $laCouleur);
|
||||
$iPrevX = $x;
|
||||
$iPrevY = $y;
|
||||
}
|
||||
}
|
||||
|
||||
public function drawDots($vImage, $vColor, $iPosX = 0, $iPosY = false, $iDotSize = 1) {
|
||||
if ($iPosY === false)
|
||||
$iPosY = imagesy($vImage);
|
||||
$vBorderColor = imagecolorallocate($vImage, 0, 0, 0);
|
||||
foreach ($this->aCoords as $x => $y) {
|
||||
imagefilledellipse($vImage, $iPosX + round($x), $iPosY - round($y), $iDotSize, $iDotSize, $vColor);
|
||||
imageellipse($vImage, $iPosX + round($x), $iPosY - round($y), $iDotSize, $iDotSize, $vBorderColor);
|
||||
}
|
||||
}
|
||||
|
||||
public function drawAxis($vImage, $vColor, $iPosX = 0, $iPosY = false) {
|
||||
if ($iPosY === false) $iPosY = imagesy($vImage);
|
||||
$vImageWidth = imagesx($vImage);
|
||||
imageline($vImage, $iPosX, $iPosY, $iPosX, 0, $vColor);
|
||||
imageline($vImage, $iPosX, $iPosY, $vImageWidth, $iPosY, $vColor);
|
||||
imagefilledpolygon($vImage, array($iPosX, 0, $iPosX - 3, 5, $iPosX + 3, 5), 3, $vColor);
|
||||
imagefilledpolygon($vImage, array($vImageWidth, $iPosY, $vImageWidth - 5, $iPosY - 3, $vImageWidth - 5, $iPosY + 3), 3, $vColor);
|
||||
}
|
||||
}
|
||||
|
||||
class CubicSplines
|
||||
{
|
||||
protected $aCoords;
|
||||
protected $aCrdX;
|
||||
protected $aCrdY;
|
||||
protected $aSplines = array();
|
||||
protected $iMinX;
|
||||
protected $iMaxX;
|
||||
protected $iStep;
|
||||
protected function prepareCoords(&$aCoords, $iStep, $iMinX = -1, $iMaxX = -1) {
|
||||
$this->aCrdX = array();
|
||||
$this->aCrdY = array();
|
||||
$this->aCoords = array();
|
||||
ksort($aCoords);
|
||||
foreach ($aCoords as $x => $y) {
|
||||
$this->aCrdX[] = $x;
|
||||
$this->aCrdY[] = $y;
|
||||
}
|
||||
$this->iMinX = $iMinX;
|
||||
$this->iMaxX = $iMaxX;
|
||||
if ($this->iMinX == -1)
|
||||
$this->iMinX = min($this->aCrdX);
|
||||
if ($this->iMaxX == -1)
|
||||
$this->iMaxX = max($this->aCrdX);
|
||||
$this->iStep = $iStep;
|
||||
}
|
||||
public function setInitCoords(&$aCoords, $iStep = 1, $iMinX = -1, $iMaxX = -1) {
|
||||
$this->aSplines = array();
|
||||
if (count($aCoords) < 4) {
|
||||
return false;
|
||||
}
|
||||
$this->prepareCoords($aCoords, $iStep, $iMinX, $iMaxX);
|
||||
$this->buildSpline($this->aCrdX, $this->aCrdY, count($this->aCrdX));
|
||||
}
|
||||
public function processCoords() {
|
||||
for ($x = $this->iMinX; $x <= $this->iMaxX; $x += $this->iStep) {
|
||||
$this->aCoords[$x] = $this->funcInterp($x);
|
||||
}
|
||||
return $this->aCoords;
|
||||
}
|
||||
private function buildSpline($x, $y, $n) {
|
||||
for ($i = 0; $i < $n; ++$i) {
|
||||
$this->aSplines[$i]['x'] = $x[$i];
|
||||
$this->aSplines[$i]['a'] = $y[$i];
|
||||
}
|
||||
$this->aSplines[0]['c'] = $this->aSplines[$n - 1]['c'] = 0;
|
||||
$alpha[0] = $beta[0] = 0;
|
||||
for ($i = 1; $i < $n - 1; ++$i) {
|
||||
$h_i = $x[$i] - $x[$i - 1];
|
||||
$h_i1 = $x[$i + 1] - $x[$i];
|
||||
$A = $h_i;
|
||||
$C = 2.0 * ($h_i + $h_i1);
|
||||
$B = $h_i1;
|
||||
$F = 6.0 * (($y[$i + 1] - $y[$i]) / $h_i1 - ($y[$i] - $y[$i - 1]) / $h_i);
|
||||
$z = ($A * $alpha[$i - 1] + $C);
|
||||
$alpha[$i] = - $B / $z;
|
||||
$beta[$i] = ($F - $A * $beta[$i - 1]) / $z;
|
||||
}
|
||||
for ($i = $n - 2; $i > 0; --$i) {
|
||||
$this->aSplines[$i]['c'] = $alpha[$i] * $this->aSplines[$i + 1]['c'] + $beta[$i];
|
||||
}
|
||||
for ($i = $n - 1; $i > 0; --$i) {
|
||||
$h_i = $x[$i] - $x[$i - 1];
|
||||
$this->aSplines[$i]['d'] = ($this->aSplines[$i]['c'] - $this->aSplines[$i - 1]['c']) / $h_i;
|
||||
$this->aSplines[$i]['b'] = $h_i * (2.0 * $this->aSplines[$i]['c'] + $this->aSplines[$i - 1]['c']) / 6.0 + ($y[$i] - $y[$i - 1]) / $h_i;
|
||||
}
|
||||
}
|
||||
private function funcInterp($x) {
|
||||
$n = count($this->aSplines);
|
||||
if ($x <= $this->aSplines[0]['x']) {
|
||||
$s = $this->aSplines[1];
|
||||
} else {
|
||||
if ($x >= $this->aSplines[$n - 1]['x']) {
|
||||
$s = $this->aSplines[$n - 1];
|
||||
} else {
|
||||
$i = 0;
|
||||
$j = $n - 1;
|
||||
while ($i + 1 < $j) {
|
||||
$k = $i + ($j - $i) / 2;
|
||||
if ($x <= $this->aSplines[$k]['x']) {
|
||||
$j = $k;
|
||||
} else {
|
||||
$i = $k;
|
||||
}
|
||||
}
|
||||
$s = $this->aSplines[$j];
|
||||
}
|
||||
}
|
||||
$dx = ($x - $s['x']);
|
||||
return $s['a'] + ($s['b'] + ($s['c'] / 2.0 + $s['d'] * $dx / 6.0) * $dx) * $dx;
|
||||
}
|
||||
}
|
||||
|
||||
define('TX_HASH_LEN',64);
|
||||
|
||||
class topisto_spline
|
||||
{
|
||||
public static function DefaultDrawBlock($the_block, $vImage, $x, $y, $graph_width, $graph_height, $type=1)
|
||||
{
|
||||
topisto_spline::DrawBlock($the_block, $vImage, $x, $y, $graph_width, $graph_height, 3.5, 1, $type);
|
||||
topisto_spline::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, $x, $y, $graph_width, $graph_height, $mode, $iterations, $type=1)
|
||||
{
|
||||
$somme = 0;
|
||||
$min =-1;
|
||||
$max = 0;
|
||||
$data = blockchain::getTransactionData($the_block, $type);
|
||||
$local_iterations = $iterations;
|
||||
$n_data = count($data);
|
||||
|
||||
$vBgColor = imagecolorallocate($vImage, 10, 10, 10);
|
||||
imagefilledrectangle($vImage, $x, $y, $x+$graph_width, $y+$graph_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'];
|
||||
$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)])
|
||||
);
|
||||
// dan sla moitié des cas, on s'en tient au "dégradé de feu"
|
||||
if (rand(0,100) > 50) $hex_val = array('#D2691E', '#FF8C00', '#EEEEEE');
|
||||
|
||||
$rgbval = ColorGradient::hex2rgb($hex_val[0]);
|
||||
|
||||
$n = 0;
|
||||
$vColor[$n] = new ColorGradient();
|
||||
$vColor[$n]->pct = 0;
|
||||
$vColor[$n]->color = imagecolorallocatealpha($vImage, $rgbval[0], $rgbval[1], $rgbval[2], $alpha);
|
||||
|
||||
$n += 1;
|
||||
$vColor[$n] = new ColorGradient();
|
||||
$vColor[$n]->pct = 0.1;
|
||||
$vColor[$n]->color = imagecolorallocatealpha($vImage, $rgbval[0], $rgbval[1], $rgbval[2], $alpha);
|
||||
|
||||
if ($mode > 0)
|
||||
{
|
||||
$gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], 60);
|
||||
for($i=0;$i<60;$i++)
|
||||
{
|
||||
$rgbval = ColorGradient::hex2rgb($gradient[$i]);
|
||||
$n += 1;
|
||||
$vColor[$n] = new ColorGradient();
|
||||
$vColor[$n]->pct = (10+$i) / 100.0;
|
||||
$vColor[$n]->color = imagecolorallocatealpha($vImage, $rgbval[0], $rgbval[1], $rgbval[2], $alpha);
|
||||
}
|
||||
|
||||
$gradient = ColorGradient::gradient($hex_val[1], $hex_val[2],30);
|
||||
for($i=0;$i<30;$i++)
|
||||
{
|
||||
$rgbval = ColorGradient::hex2rgb($gradient[$i]);
|
||||
$n += 1;
|
||||
$vColor[$n] = new ColorGradient();
|
||||
$vColor[$n]->pct = (70+$i) / 100.0;
|
||||
$vColor[$n]->color = imagecolorallocatealpha($vImage, $rgbval[0], $rgbval[1], $rgbval[2], $alpha);
|
||||
}
|
||||
}
|
||||
|
||||
//////////
|
||||
$oCurve = new CubicSplines();
|
||||
|
||||
$marge_x = 10;
|
||||
$marge_y = 20;
|
||||
|
||||
$coef = ($graph_height - (2*$marge_y)) / $somme;
|
||||
$dx = $graph_width;
|
||||
if ($mode > 0) $dx = round($dx / (TX_HASH_LEN+1));
|
||||
|
||||
//$limite_x = $x + ($graph_width - $marge_x);
|
||||
$limite_x = $x + $graph_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 + ($graph_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
69
methode/spline/robot.php
Normal file
69
methode/spline/robot.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
// ---
|
||||
// --- Listening to blockchain.info to get the last block
|
||||
// ---
|
||||
|
||||
// ---
|
||||
// --- La config globale
|
||||
// ---
|
||||
require_once '../../global/inc/config.php';
|
||||
|
||||
// ---
|
||||
// --- Internal dependances
|
||||
// ---
|
||||
require_once APP_PATH.'/blockchain/inc/block.php';
|
||||
require_once 'inc/splines.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]);
|
||||
|
||||
$iterations = 1;
|
||||
if ($mode > 2) $iterations = 200;
|
||||
if (isset($argv[3])) $iterations=intval($argv[3]);
|
||||
|
||||
$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);
|
||||
|
||||
$x0=0; $y0=$bandeau;
|
||||
$type=2;
|
||||
if (count($the_block->tx) == 1) $type = 4;
|
||||
|
||||
blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
|
||||
|
||||
topisto_spline::DrawBlock($the_block, $img, $x0, $y0, $width, $height, $mode, $iterations, $type);
|
||||
|
||||
imagepng($img, DATA_PATH.'/spline/'.$the_block->hash.'.png');
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
?>
|
||||
33
methode/spline/robot.sh
Executable file
33
methode/spline/robot.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
flag=$TMP_PATH/spline_bot.flag
|
||||
date=`date +%Y%m%d0000`
|
||||
|
||||
if [ -f $flag ];
|
||||
then
|
||||
echo "spline_bot is already running !"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
touch $flag
|
||||
|
||||
cd $APPS_PATH/methode/spline
|
||||
for BLOCK in `awk '{print $2}' $DATA_PATH/block_list.txt`
|
||||
do
|
||||
if [ ! -f $DATA_PATH/spline/$BLOCK.png ]
|
||||
then
|
||||
php robot.php $BLOCK
|
||||
fi
|
||||
|
||||
BNAME=`grep $BLOCK $DATA_PATH/block_list.txt | awk '{print $1}'`
|
||||
if [ "$BNAME" == "LAST" ]
|
||||
then
|
||||
touch $DATA_PATH/spline/$BLOCK.png
|
||||
else
|
||||
touch -t $date $DATA_PATH/spline/$BLOCK.png
|
||||
fi
|
||||
|
||||
rm -f $DATA_PATH/hasard/$BLOCK.png
|
||||
ln $DATA_PATH/spline/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
|
||||
done
|
||||
|
||||
rm -f $flag
|
||||
156
methode/treemap/inc/treemap.php
Normal file
156
methode/treemap/inc/treemap.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?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, $x, $y, $width, $height, $methode, $type=1)
|
||||
{
|
||||
$full_area = $width * $height;
|
||||
if ($full_area == 0) $full_area = 1;
|
||||
|
||||
$data = blockchain::getTransactionData($the_block, $type);
|
||||
|
||||
$vBgColor = imagecolorallocate($vImage, 10, 10, 10);
|
||||
imagefilledrectangle($vImage, $x, $y, $x+$width, $y+$height, $vBgColor);
|
||||
|
||||
// quelques gradient de couleurs ...
|
||||
$rgb1 = [rand(0,255),rand(0,255),rand(0,255)];
|
||||
$rgb2 = [rand(0,255),rand(0,255),rand(0,255)];
|
||||
|
||||
$gradient = [];
|
||||
$gradient[] = new Gradient(['0.0' => '#f75557', '0.5' => '#646a82', '1.0' => '#5ad87b']);
|
||||
$gradient[] = new Gradient(['0.0' => '#FF69B4', '1.0' => '#FF5555']);
|
||||
$gradient[] = new Gradient(['0.0' => rgb2hex($rgb1), '1.0' => rgb2hex($rgb2)]);
|
||||
$gradient[] = new Gradient(['0.0' => '#FFFFFF', '1.0' => '#000000']);
|
||||
|
||||
if ($type == 4)
|
||||
{
|
||||
// Cas particulier pour la récompense
|
||||
$reward = 0;
|
||||
foreach($data as $v) $reward += $v['value'];
|
||||
$pct = $reward / 5000000000.0;
|
||||
$w = round($width * $pct);
|
||||
$h = round($height * $pct);
|
||||
$x1 = $x + (($width/2) - ($w /2));
|
||||
$y1 = $y + (($height/2) - ($h /2));
|
||||
$rgb = self::getRGB($methode, $gradient, $pct*100);
|
||||
$vFgColor = imagecolorallocate($vImage, $rgb[0], $rgb[1], $rgb[2]);
|
||||
$rgb = self::getRGB(999, $gradient, $pct*100);
|
||||
$vBgColor = imagecolorallocate($vImage, $rgb[0], $rgb[1], $rgb[2]);
|
||||
if (($h < 2)&&($w< 2))
|
||||
{
|
||||
imagesetpixel($vImage, $x1, $y1, $vFgColor);
|
||||
} else {
|
||||
$x2 = $x1 + $w;
|
||||
$y2 = $y1 + $h;
|
||||
imagefilledrectangle($vImage, $x1, $y1, $x2, $y2, $vFgColor);
|
||||
imagerectangle($vImage, $x1, $y1, $x2, $y2, $vBgColor);
|
||||
}
|
||||
} else {
|
||||
$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;
|
||||
|
||||
// if (($x1 == ($x+$width))||($x1 == ($y+$height))) break;
|
||||
|
||||
$rgb = self::getRGB($methode, $gradient, $factor);
|
||||
// Pas de noir absolu
|
||||
if (($rgb[0]+$rgb[1]+$rgb[2]) == 0)
|
||||
$vFgColor = imagecolorallocate($vImage, 10, 10, 10);
|
||||
else
|
||||
$vFgColor = imagecolorallocate($vImage, $rgb[0], $rgb[1], $rgb[2]);
|
||||
|
||||
$rgb = self::getRGB(999, $gradient, $factor);
|
||||
$vBgColor = imagecolorallocate($vImage, $rgb[0], $rgb[1], $rgb[2]);
|
||||
|
||||
$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);
|
||||
|
||||
imagefilledrectangle($vImage, $x1, $y1, $x2, $y2, $vFgColor);
|
||||
if ((($x2-$x1) > 2)||(($y2-$y1) > 2))
|
||||
imagerectangle($vImage, $x1, $y1, $x2, $y2, $vBgColor);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
81
methode/treemap/robot.php
Normal file
81
methode/treemap/robot.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?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, 0, $bandeau, $width, $height, $mode, $type);
|
||||
|
||||
imagepng($img, DATA_PATH.'/treemap/'.$the_block->hash.'.png');
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
?>
|
||||
32
methode/treemap/robot.sh
Executable file
32
methode/treemap/robot.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
flag=$TMP_PATH/treemap_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/treemap
|
||||
for BLOCK in `awk '{print $2}' $DATA_PATH/block_list.txt`
|
||||
do
|
||||
if [ ! -f $DATA_PATH/treemap/$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/treemap/$BLOCK.png
|
||||
else
|
||||
touch -t $date $DATA_PATH/treemap/$BLOCK.png
|
||||
fi
|
||||
|
||||
rm -f $DATA_PATH/hasard/$BLOCK.png
|
||||
ln $DATA_PATH/treemap/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
|
||||
done
|
||||
|
||||
rm -f $flag
|
||||
118
methode/treemapV2/inc/treemap.php
Normal file
118
methode/treemapV2/inc/treemap.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
81
methode/treemapV2/robot.php
Normal file
81
methode/treemapV2/robot.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?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);
|
||||
|
||||
?>
|
||||
32
methode/treemapV2/robot.sh
Executable file
32
methode/treemapV2/robot.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/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
|
||||
92
methode/treemap_fuzzy/inc/treemap.php
Normal file
92
methode/treemap_fuzzy/inc/treemap.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?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_treemap_fuzzy
|
||||
{
|
||||
public static function DrawBlock($the_block, $vImage, $x, $y, $width, $height, $mode, $type=1)
|
||||
{
|
||||
$min =-1;
|
||||
$max = 0;
|
||||
$data = blockchain::getTransactionData($the_block, $type);
|
||||
|
||||
$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;
|
||||
|
||||
$tDrawColor = array();
|
||||
$tDrawColor[0] = imagecolorallocatealpha($vImage, 140, 246, 138, 125);
|
||||
$tDrawColor[1] = imagecolorallocatealpha($vImage, 200, 200, 200, 125);
|
||||
|
||||
$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, $tDrawColor[1]);
|
||||
} 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 = $h * $w;
|
||||
for($i=0;$i<$ww;$i++)
|
||||
{
|
||||
$vDrawColor2 = $tDrawColor[$i%2];
|
||||
|
||||
$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, $vDrawColor2);
|
||||
imageline($vImage, $x2_1, $y2_1, $x3_1, $y3_1, $vDrawColor2);
|
||||
imageline($vImage, $x3_1, $y3_1, $x4_1, $y4_1, $vDrawColor2);
|
||||
imageline($vImage, $x4_1, $y4_1, $x1_1, $y1_1, $vDrawColor2);
|
||||
}
|
||||
}
|
||||
$mm -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
69
methode/treemap_fuzzy/robot.php
Normal file
69
methode/treemap_fuzzy/robot.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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;
|
||||
|
||||
blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
|
||||
|
||||
topisto_treemap_fuzzy::DrawBlock($the_block, $img, 0, $bandeau, $width, $height, $mode, $type);
|
||||
|
||||
imagepng($img, DATA_PATH.'/treemap_fuzzy/'.$the_block->hash.'.png');
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
?>
|
||||
33
methode/treemap_fuzzy/robot.sh
Executable file
33
methode/treemap_fuzzy/robot.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
flag=$TMP_PATH/treemap_fuzzy_bot.flag
|
||||
date=`date +%Y%m%d0000`
|
||||
|
||||
if [ -f $flag ];
|
||||
then
|
||||
echo "treemap_fuzzy_bot is already running !"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
touch $flag
|
||||
|
||||
cd $APPS_PATH/methode/treemap_fuzzy
|
||||
for BLOCK in `awk '{print $2}' $DATA_PATH/block_list.txt`
|
||||
do
|
||||
if [ ! -f $DATA_PATH/treemap_fuzzy/$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/treemap_fuzzy/$BLOCK.png
|
||||
else
|
||||
touch -t $date $DATA_PATH/treemap_fuzzy/$BLOCK.png
|
||||
fi
|
||||
|
||||
rm -f $DATA_PATH/hasard/$BLOCK.png
|
||||
ln $DATA_PATH/treemap_fuzzy/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
|
||||
done
|
||||
|
||||
rm -f $flag
|
||||
103
methode/veraMolnar/inc/treemap.php
Normal file
103
methode/veraMolnar/inc/treemap.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
83
methode/veraMolnar/robot.php
Normal file
83
methode/veraMolnar/robot.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?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);
|
||||
|
||||
?>
|
||||
33
methode/veraMolnar/robot.sh
Executable file
33
methode/veraMolnar/robot.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user