Ajout mode triptyque
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
// ---
|
||||
// --- 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';
|
||||
|
||||
// ---
|
||||
// --- Par défaut on cherche le dernier block
|
||||
// --- Le cas échéant, on cherche block passé en argument
|
||||
// ---
|
||||
$block_hash0 = 'LAST';
|
||||
if (isset($argv[1])) $block_hash0 = $argv[1];
|
||||
|
||||
$block_hash1 = 'LAST';
|
||||
if (isset($argv[2])) $block_hash1 = $argv[2];
|
||||
|
||||
$block_hash2 = 'LAST';
|
||||
if (isset($argv[3])) $block_hash2 = $argv[3];
|
||||
|
||||
$the_block = blockchain::getBlockWithHash($block_hash0);
|
||||
if ($the_block === FALSE) die();
|
||||
|
||||
$taille=1;
|
||||
|
||||
$bandeau = 50;
|
||||
$marge = 25;
|
||||
$text_border = 20;
|
||||
$width = GRAPH_WIDTH * $taille;
|
||||
$height = GRAPH_HEIGHT * $taille;
|
||||
$couleur = -1; // Au hasard
|
||||
|
||||
// Pour que l'image simple ait les proportions que l'image full
|
||||
$width = $marge + ($width*2) + (2*$text_border);
|
||||
$height = $marge + ($height*2);
|
||||
|
||||
// création d'une image plus haute pour inclure bandeaux haut et bas
|
||||
$img_w = $width;
|
||||
$img_h = ($height+(2*$bandeau));
|
||||
|
||||
$decal=5;
|
||||
$y=0-($img_h/2);
|
||||
|
||||
$img = imagecreatetruecolor($img_w+10, ($img_h*2)-($decal*2));
|
||||
|
||||
// on met une couleur transparente sur le fond
|
||||
//$white = imagecolorallocate($img, 254, 254, 254);
|
||||
//imagecolortransparent($img, $white);
|
||||
//imagefilledrectangle($img, 0, 0, $img_w, ($img_h*3)-($decal*2), $white);
|
||||
|
||||
$img_block=imagecreatefrompng(DATA_PATH.'/nonce/'.$block_hash0.'.png');
|
||||
imagecopy($img, $img_block,5,$y,0,0,$img_w, $img_w);
|
||||
imagedestroy($img_block);
|
||||
|
||||
$y+=$img_h - $decal;
|
||||
$img_block=imagecreatefrompng(DATA_PATH.'/nonce/'.$block_hash1.'.png');
|
||||
imagecopy($img, $img_block,5,$y,0,0,$img_w, $img_w);
|
||||
imagedestroy($img_block);
|
||||
|
||||
$y+=$img_h - $decal;
|
||||
$img_block=imagecreatefrompng(DATA_PATH.'/nonce/'.$block_hash2.'.png');
|
||||
imagecopy($img, $img_block,5,$y,0,0,$img_w, $img_w);
|
||||
imagedestroy($img_block);
|
||||
|
||||
// Draw a white rectangle
|
||||
$black = imagecolorallocate($img, 0, 0, 0);
|
||||
imagefilledrectangle($img, 0, 0, $img_w+10, 5, $black);
|
||||
imagefilledrectangle($img, 0, ($img_h*2)-($decal*2)-5, $img_w+10, ($img_h*2)-($decal*2), $black);
|
||||
|
||||
imagepng($img, DATA_PATH.'/triptyque/'.$block_hash1.'.png');
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user