Graphique d hemicycle

blbl38
Invité n'ayant pas de compte PHPfrance

31 oct. 2010, 13:33

Bonjour à tous,

Je viens pour savoir si il est possible de faire facilement !!
et ce de facon a pas utiliser 45 images que je chargerai en fonction des resultats de vote

donc comment faire pour que le script represente 1 de 15 zones
comme ceci
Image
chaque couleur la represente un deputé
si la proposition de loi est accepté, ca sera vert
rouge refusée
orange vote blanc

Donc comment faire pour que le script gere ca ?
Merci a savoir que si y a des formules de maths, je n ai qu un noveau 5e ,

Merci encore

ViPHP
AB
ViPHP | 5818 Messages

31 oct. 2010, 15:02

Ben tu t'attaque pas au plus facile. Ce serait mieux de faire plus d'exercices en php avant d'attaquer ce chapitre de création d'images.

Pour l'instant, en attendant d'acquérir une expérience plus importante, le plus simple et le plus rapide sera de faire tes 45 images et de les charger en fonction des résultats, ce qui constitue déjà un exercice d'organisation intéressant.

ViPHP
ViPHP | 2291 Messages

01 nov. 2010, 01:10

Salut,

Voici une piste, mais c'est un simple exemple il est possible de faire beaucoup mieux :)
<?php

/*
* Création de l'image
*/
$image = imagecreatetruecolor(400, 400);
$black = imagecolorallocate($image, 0, 0, 0);

/*
* On rend l'arrière-plan transparent.
*/
imagecolortransparent($image, $black);


/*
* Création des couleurs.
*/
$vert   = imagecolorallocate($image, 0x00, 0xFF, 0x40); //Oui.
$rouge  = imagecolorallocate($image, 0xFF, 0x00, 0x00); //Non.
$orange = imagecolorallocate($image, 0xFF, 0x80, 0x00); //Null.



/*
* Récup des données des députés.
*/

$d1 = $vert;
$d2 = $rouge;
$d3 = $orange;
$d4 = $orange;
$d5 = $vert;
$d6 = $orange;
$d7  = $rouge;
$d8 = $orange;
$d9 = $vert;
$d10 = $orange;
$d11 = $rouge;
$d12 = $orange;
$d13 = $orange;
$d14 = $rouge;
$d15 = $orange;



    /*
    * Création des cartiers.
    */

    imagefilledarc($image, 200, 200, 400, 400, 180, 0, $d1, IMG_ARC_PIE);
    imagefilledarc($image, 200, 200, 400, 400, 192, 0, $d2, IMG_ARC_PIE);
    imagefilledarc($image, 200, 200, 400, 400, 204, 0, $d3, IMG_ARC_PIE);
    imagefilledarc($image, 200, 200, 400, 400, 216, 0, $d4, IMG_ARC_PIE);
    imagefilledarc($image, 200, 200, 400, 400, 228, 0, $d5, IMG_ARC_PIE);
    imagefilledarc($image, 200, 200, 400, 400, 240, 0, $d6, IMG_ARC_PIE);
    imagefilledarc($image, 200, 200, 400, 400, 252, 0, $d7, IMG_ARC_PIE);
    imagefilledarc($image, 200, 200, 400, 400, 264, 0, $d8, IMG_ARC_PIE);
    imagefilledarc($image, 200, 200, 400, 400, 276, 0, $d9, IMG_ARC_PIE);
    imagefilledarc($image, 200, 200, 400, 400, 288, 0, $d10, IMG_ARC_PIE);
    imagefilledarc($image, 200, 200, 400, 400, 300, 0, $d11, IMG_ARC_PIE);
    imagefilledarc($image, 200, 200, 400, 400, 312, 0, $d12, IMG_ARC_PIE);
    imagefilledarc($image, 200, 200, 400, 400, 324, 0, $d14, IMG_ARC_PIE);
 	imagefilledarc($image, 200, 200, 400, 400, 336, 0, $d15, IMG_ARC_PIE);





/*
* Affichage de l'image.
*/
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>


La doc est ici
ImageCe que l'on apprend par l'effort reste toujours ancré beaucoup plus longtemps.