begin process at 2012 05 27 22:19:37
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Class et Objet ( POO )

 > 2 OU 3 CLASSES D'MAGES EN PHP5 COMPOSITION D'UNE ÉQUIPE DE FOOT

2 OU 3 CLASSES D'MAGES EN PHP5 COMPOSITION D'UNE ÉQUIPE DE FOOT


 Information sur la source

Note :
10 / 10 - par 1 personne
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Class et Objet ( POO ) Classé sous :images, football, génération, basket Niveau :Débutant Date de création :11/02/2006 Date de mise à jour :13/02/2006 20:10:28 Vu / téléchargé :7 246 / 390

Auteur : guill76

Ecrire un message privé
Commentaire sur cette source (17)
Ajouter un commentaire et/ou une note

 Description

Je viens de me mettre depuis 2 jours à GD et je m'éclate avec ces fonctions:
J'ai créé tous d'abord une classe image simple, puis 3 classes héritées (LOGO, SOCCERGROUND, ET COMPOSITIONGRAPH)
C'est avec cette dernière que je me suis mis à délirer pour mettre à jour la composition d'une equipe de foot sur un terrain (le tout constituant une image dynamique) .
Si vous avez des remarques ou des améliorations je vous écoute.
Je vous livre le tout sans faire le tri.
la classe logo est complétement expérimentale(brouillonne) puisque je découvre mais bon...

Source

  • <?php
  • class IMGBASE {
  • protected $width;
  • protected $height;
  • protected $bgcolor; //RESSOURCE COLOR
  • protected $pic; //RESSOURCE IMAGE
  • protected $format;
  • protected $name;
  • protected $extension;
  • public function __construct ($pwidth=100, $pheight=100, $pR=245, $pG=245, $pB=245, $pformat='image/png'){
  • $this->width = $pwidth;
  • $this->height = $pheight;
  • $this->format = $pformat;
  • $this->name = 'tmp';
  • if (!($this->pic = imagecreate ($this->width, $this->height)))
  • throw new Exception ('<font color ="red"><b>EXCEPTION ATTRAPEE :impossible de creer l\'image.</b></font>');
  • if (($this->bgcolor = imagecolorallocate ($this->pic, $pR, $pG, $pB))===-1)
  • throw new Exception ('<font color ="red"><b>EXCEPTION ATTRAPEE :Impossible d\'allouer une couleur de fond</b></font>');
  • }
  • public function setname ($name){
  • $this->name = $name;
  • }
  • public function display() {
  • $this->tofile();
  • echo '<img src="'.$this->name.'.'.$this->extension.'">';
  • }
  • public function toscreen(){
  • if (!$this->pic) throw new Exception ('Impossible d afficher l\'image');
  • $a=array('image/jpeg'=>'imagejpeg', 'image/png'=>'imagepng', 'image/gif'=>'imagegif');
  • $b=$a[$this->format];
  • $b($this->pic);
  • }
  • public function tofile(){
  • if (!is_dir(dirname( $this->name)))
  • throw new Exception ('Impossible de créer le fichier '.$this->name.' dans le répertoire '.dirname($this->name));
  • $a=array('image/jpeg'=>'imagejpeg', 'image/png'=>'imagepng', 'image/gif'=>'imagegif');
  • $b=$a[$this->format];
  • $b($this->pic,$this->name.'.'.$this->extension);
  • if ($this->pic)
  • imagedestroy($this->pic);
  • }
  • }
  • class SOCCERGROUND extends IMGBASE {
  • protected $scale ;//on multiplie la valeur en pixel par ce nombre pour avoir l'affichage
  • private $lineclr;// COULEUR DE LIGNE
  • private $darkgrass;//ID COULEUR DE TONTE
  • private function colorizegrass(){
  • $this->darkgrass = imagecolorallocate ($this->pic, 0, 120, 0);
  • for ($i=1 ; $i < 17 ; $i+=2){
  • imagefilledrectangle ($this->pic, 0, $i*($this->height/16), $this->width, ($i+1)*($this->height/16), $this->darkgrass);
  • }
  • }
  • public function setscale ($sc){
  • $this->scale=$sc;
  • }
  • public function __construct($w=70,$h=105,$sc=5){
  • $this->scale = $sc;
  • parent::__construct($w*$this->scale, $h*$this->scale, 0, 150, 0, 'image/png');
  • $this->lineclr = imagecolorallocate ($this->pic, 255, 255, 255);
  • }
  • private function draw_mediane () {
  • imageline($this->pic, 0, $this->height/2, $this->width, $this->height/2, $this->lineclr);
  • }
  • private function draw_medium_circle () {
  • imageellipse ($this->pic, $this->width/2, $this->height/2, 18.3*$this->scale, 18.3*$this->scale, $this->lineclr);
  • imagefilledellipse(
  • $this->pic,
  • $this->width/2,
  • $this->height/2,
  • 5,
  • 5,
  • $this->lineclr
  • );
  • }
  • private function draw_gk_zone () {
  • $XUpMd = $this->width/2;
  • $YUpMd = 0;
  • $XDnMd = $this->width/2;
  • $YDnMd = $this->height;
  • //BUT DU HAUT
  • imageline (
  • $this->pic,
  • $XUpMd-((7 * ($this->scale))/2),
  • $YUpMd ,
  • $XUpMd-((7 * ($this->scale))/2),
  • $YUpMd + 5,
  • $this->lineclr
  • );
  • imageline (
  • $this->pic,
  • $XUpMd+((7 * ($this->scale))/2),
  • $YUpMd ,
  • $XUpMd+((7 * ($this->scale))/2),
  • $YUpMd + 5,
  • $this->lineclr
  • );
  • //BUT DU BAS
  • imageline (
  • $this->pic,
  • $XDnMd-((7 * ($this->scale))/2),
  • $YDnMd ,
  • $XDnMd-((7 * ($this->scale))/2),
  • $YDnMd - 10,
  • $this->lineclr
  • );
  • imageline (
  • $this->pic,
  • $XDnMd+((7 * ($this->scale))/2),
  • $YDnMd ,
  • $XDnMd+((7 * ($this->scale))/2),
  • $YDnMd - 10,
  • $this->lineclr
  • );
  • imageline (
  • $this->pic,
  • $XDnMd - ((7 * ($this->scale))/2),
  • $YDnMd - 10,
  • $XDnMd + ((7 * ($this->scale))/2),
  • $YDnMd - 10,
  • $this->lineclr
  • );
  • //PETIT RECTANGLE BUT DU BAS
  • imageline (
  • $this->pic,
  • $XDnMd - (9 * $this->scale),
  • $YDnMd,
  • $XDnMd - (9 * $this->scale),
  • $YDnMd - (5.5 * $this->scale),
  • $this->lineclr
  • );
  • imageline (
  • $this->pic,
  • $XDnMd + (9 * $this->scale),
  • $YDnMd,
  • $XDnMd + (9 * $this->scale),
  • $YDnMd - (5.5 * $this->scale),
  • $this->lineclr
  • );
  • imageline (
  • $this->pic,
  • $XDnMd - (9 * $this->scale),
  • $YDnMd - (5.5 * $this->scale),
  • $XDnMd + (9 * $this->scale),
  • $YDnMd - (5.5 * $this->scale),
  • $this->lineclr
  • );
  • //PETIT RECTANGLE BUT DU HAUT
  • imageline (
  • $this->pic,
  • $XUpMd - (9 * $this->scale),
  • $YUpMd,
  • $XUpMd - (9 * $this->scale),
  • $YUpMd + (5.5 * $this->scale),
  • $this->lineclr
  • );
  • imageline (
  • $this->pic,
  • $XUpMd + (9 * $this->scale),
  • $YUpMd,
  • $XUpMd + (9 * $this->scale),
  • $YUpMd + (5.5 * $this->scale),
  • $this->lineclr
  • );
  • imageline (
  • $this->pic,
  • $XUpMd - (9 * $this->scale),
  • $YUpMd + (5.5 * $this->scale),
  • $XUpMd + (9 * $this->scale),
  • $YUpMd + (5.5 * $this->scale),
  • $this->lineclr
  • );
  • //POINT PENALTY DU HAUT
  • imagefilledellipse(
  • $this->pic,
  • $XUpMd,
  • 11 * $this->scale,
  • 5,
  • 5,
  • $this->lineclr
  • );
  • //POINT PENALTY DU BAS
  • imagefilledellipse(
  • $this->pic,
  • $XDnMd,
  • $YDnMd-(11 * $this->scale),
  • 5,
  • 5,
  • $this->lineclr
  • );
  • //SURFACE DU HAUT
  • imageline (
  • $this->pic,
  • $XUpMd - (20*$this->scale),
  • 0,
  • $XUpMd - (20*$this->scale),
  • 16.5 * $this->scale,
  • $this->lineclr
  • );
  • imageline (
  • $this->pic,
  • $XUpMd + (20*$this->scale),
  • 0,
  • $XUpMd + (20*$this->scale),
  • 16.5 * $this->scale,
  • $this->lineclr
  • );
  • imageline (
  • $this->pic,
  • $XUpMd - (20*$this->scale),
  • 16.5 * $this->scale,
  • $XUpMd + (20*$this->scale),
  • 16.5 * $this->scale,
  • $this->lineclr
  • );
  • //SURFACE DU BAS
  • imageline (
  • $this->pic,
  • $XDnMd - (20*$this->scale),
  • $YDnMd,
  • $XDnMd - (20*$this->scale),
  • $YDnMd - (16.5 * $this->scale),
  • $this->lineclr
  • );
  • imageline (
  • $this->pic,
  • $XDnMd + (20*$this->scale),
  • $YDnMd,
  • $XDnMd + (20*$this->scale),
  • $YDnMd - (16.5 * $this->scale),
  • $this->lineclr
  • );
  • imageline (
  • $this->pic,
  • $XDnMd - (20*$this->scale),
  • $YDnMd - (16.5 * $this->scale),
  • $XDnMd + (20*$this->scale),
  • $YDnMd - (16.5 * $this->scale),
  • $this->lineclr
  • );
  • //ARC BAS
  • imagearc(
  • $this->pic,
  • $XDnMd,
  • $YDnMd-(11 * $this->scale),
  • 18.3 * $this->scale,
  • 18.3 * $this->scale,
  • 180+36.95,
  • -36.95,
  • $this->lineclr
  • );
  • //ARC HAUT
  • imagearc(
  • $this->pic,
  • $XUpMd,
  • 11 * $this->scale,
  • 18.3 * $this->scale,
  • 18.3 * $this->scale,
  • +36.95,
  • 180-36.95,
  • $this->lineclr
  • );
  • }
  • public function rotate($deg){
  • $white = imagecolorallocate($this->pic, 255, 255, 255);
  • $this->pic = imagerotate($this->pic, $deg, $white);
  • }
  • public function build (){
  • $this->colorizegrass();
  • $this->draw_mediane();
  • $this->draw_medium_circle();
  • $this->draw_gk_zone ();
  • }
  • }
  • class COMPOSITIONGRAPH extends SOCCERGROUND{
  • private $team = array();
  • protected $txtcolor;
  • protected $fontsize;
  • protected $numcolor;
  • protected $numsize;
  • protected $font;
  • public function __construct($tm=NULL,$psc=5){
  • parent::__construct(70,105,$psc);
  • if (isset($tm)&&is_array($tm) ){
  • $this->team = $tm;
  • //echo $tm[0]['poste'];
  • }else throw new Exception('ERREUR DANS LE TABLEAU team');
  • $this->txtcolor = imagecolorallocate ($this->pic, 0, 0, 200);
  • $this->numcolor = imagecolorallocate ($this->pic, 255, 0, 0);
  • $this->fontsize = 3;
  • $this->numsize = 4;
  • }
  • /* public function rotate180(){
  • $this->pic=imagerotate($this->pic,180,0);
  • }*/
  • public function settxtstyle($R,$G,$B,$sz){
  • $this->txtcolor = imagecolorallocate ($this->pic, $R, $G, $B);
  • $this->fontsize = $sz;
  • }
  • public function setnumstyle($R,$G,$B,$sz){
  • $this->numcolor = imagecolorallocate ($this->pic, $R, $G, $B);
  • $this->numsize = $sz;
  • }
  • private function incrust_player ( $cx, $cy, $name, $num){
  • $textwidth = (strlen($name)*($this->fontsize+4))/2;
  • $numwidth = (strlen($num)*($this->numsize+4))/2;
  • imagestring(
  • $this->pic,
  • $this->fontsize,
  • $cx - $textwidth,
  • $cy,
  • $name,
  • $this->txtcolor);
  • imagestring(
  • $this->pic,
  • $this->numsize,
  • $cx-$numwidth,
  • $cy + 12,
  • $num,
  • $this->numcolor);
  • }
  • protected function writeongraph ($location='UP'){
  • if ( (isset($this->team)&& is_array($this->team)) ){
  • $n = count ($this->team);
  • for( $i=0 ; $i < $n ; $i++){
  • switch ($this->team[$i]['poste']){
  • case 'GB':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( ($this->width/2), 7*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else
  • $this->incrust_player ( ($this->width/2),$this->height-(11*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'ArCD':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( 2*($this->width/6), 21*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else $this->incrust_player ( 4*($this->width/6),$this->height-(25*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'ArCG':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( 4*($this->width/6), 21*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else $this->incrust_player ( 2*($this->width/6),$this->height-(25*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'ArCC':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( ($this->width/2), 21*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else
  • $this->incrust_player ( ($this->width/2), $this->height-(25*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'ArLD':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( ($this->width/7), 30*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else $this->incrust_player ( 6*($this->width/7), $this->height-(35*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'ArLG':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( 6*($this->width/7), 30*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else $this->incrust_player ( ($this->width/7), $this->height-(35*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'MDC':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( $this->width/2, 35*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else
  • $this->incrust_player ( $this->width/2, $this->height - (40*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'MDD':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( $this->width/3, 35*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else
  • $this->incrust_player ( 2*($this->width/3), $this->height - (40*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'MDG':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( 2*($this->width/3), 35*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else
  • $this->incrust_player ( ($this->width/3), $this->height - (40*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'MOD':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( $this->width/3, 40*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else
  • $this->incrust_player ( 2*($this->width/3), $this->height - (50*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'MOG':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( 2*($this->width/3), 40*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else
  • $this->incrust_player (($this->width/3), $this->height - (50*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'MOC':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( $this->width/2, 40*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else
  • $this->incrust_player ( $this->width/2, $this->height - (50*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'AvD':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( $this->width/6, 55*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else
  • $this->incrust_player ( 5*($this->width/6), $this->height - (60*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'AvG':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( 5*($this->width/6), 55*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else
  • $this->incrust_player ( ($this->width/6), $this->height - (60*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'AvCD':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( $this->width/3, 55*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else
  • $this->incrust_player ( 2*($this->width/3), $this->height - (60*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'AvCG':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( 2*($this->width/3), 55*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else
  • $this->incrust_player ( ($this->width/3), $this->height - (60*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • case 'AvCC':
  • if ($this->team[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( $this->width/2, 55*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
  • else
  • $this->incrust_player ( $this->width/2, $this->height - (60*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
  • }
  • break;
  • }
  • }
  • }
  • else throw new Exception ('ERREUR DANS LE TABLEAU team');
  • }
  • public function build($location='UP') {
  • parent::build();
  • $this->writeongraph($location);
  • }
  • }
  • class GRAPHDOMEXT extends COMPOSITIONGRAPH {
  • private $teamext;
  • private $colorext;
  • private $numcolorext;
  • public function __construct($tabdom, $tabext, $sc=5) {
  • parent::__construct($tabdom, $sc);
  • $this->teamext=$tabext;
  • $this->colorext = imagecolorallocate($this->pic,0,0,120);
  • $this->numcolorext = imagecolorallocate($this->pic,120,0,0);
  • }
  • private function incrust_player ( $cx, $cy, $name, $num){
  • $textwidth = (strlen($name)*($this->fontsize+4))/2;
  • $numwidth = (strlen($num)*($this->numsize+4))/2;
  • imagestring(
  • $this->pic,
  • $this->fontsize,
  • $cx - $textwidth,
  • $cy,
  • $name,
  • $this->colorext);
  • imagestring(
  • $this->pic,
  • $this->numsize,
  • $cx-$numwidth,
  • $cy + 12,
  • $num,
  • $this->numcolorext);
  • }
  • public function build($location='UP') {
  • parent::build();
  • $this->writeongraph($location);
  • $this->addteamextongraph();
  • }
  • public function addteamextongraph ($location='DOWN'){
  • if ( (isset($this->teamext)&& is_array($this->teamext)) ){
  • $n = count ($this->teamext);
  • for( $i=0 ; $i < $n ; $i++){
  • switch ($this->teamext[$i]['poste']){
  • case 'GB':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( ($this->width/2), 7*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else
  • $this->incrust_player ( ($this->width/2),$this->height-(11*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'ArCD':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( 2*($this->width/6), 21*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else $this->incrust_player ( 4*($this->width/6),$this->height-(25*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'ArCG':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( 4*($this->width/6), 21*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else $this->incrust_player ( 2*($this->width/6),$this->height-(25*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'ArCC':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( ($this->width/2), 21*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else
  • $this->incrust_player ( ($this->width/2), $this->height-(25*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'ArLD':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( ($this->width/7), 30*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else $this->incrust_player ( 6*($this->width/7), $this->height-(35*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'ArLG':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( 6*($this->width/7), 30*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else $this->incrust_player ( ($this->width/7), $this->height-(35*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'MDC':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( $this->width/2, 35*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else
  • $this->incrust_player ( $this->width/2, $this->height - (40*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'MDD':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( $this->width/3, 35*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else
  • $this->incrust_player ( 2*($this->width/3), $this->height - (40*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'MDG':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( 2*($this->width/3), 35*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else
  • $this->incrust_player ( ($this->width/3), $this->height - (40*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'MOD':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( $this->width/3, 45*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else
  • $this->incrust_player ( 2*($this->width/3), $this->height - (45*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'MOG':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( 2*($this->width/3), 45*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else
  • $this->incrust_player (($this->width/3), $this->height - (45*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'MOC':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( $this->width/2, 45*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else
  • $this->incrust_player ( $this->width/2, $this->height - (45*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'AvD':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( $this->width/6, 55*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else
  • $this->incrust_player ( 5*($this->width/6), $this->height - (60*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'AvG':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( 5*($this->width/6), 55*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else
  • $this->incrust_player ( ($this->width/6), $this->height - (60*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'AvCD':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( $this->width/3, 55*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else
  • $this->incrust_player ( 2*($this->width/3), $this->height - (60*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'AvCG':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( 2*($this->width/3), 55*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else
  • $this->incrust_player ( ($this->width/3), $this->height - (60*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • case 'AvCC':
  • if ($this->teamext[$i]['titulaire']){
  • if ($location=='UP')
  • $this->incrust_player ( $this->width/2, 55*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • else
  • $this->incrust_player ( $this->width/2, $this->height - (60*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
  • }
  • break;
  • }
  • }
  • }
  • else throw new Exception('ERREUR DANS LE TABLEAU teamext');
  • }
  • }
  • class BASKETGROUND extends IMGBASE{
  • protected $scale;
  • private $lineclr;// COULEUR DE LIGNE
  • private $basketclr;
  • public function __construct($w=15,$h=28,$sc=20){
  • $this->scale = $sc;
  • parent::__construct($w*$this->scale, $h*$this->scale, 228, 202, 152, 'image/png');
  • //$this->bgcolor1 = imagecolorallocate ($this->pic ,228,202,152);
  • $this->lineclr = imagecolorallocate ($this->pic, 255, 255, 255);
  • }
  • public function rotate ($deg) {
  • $white = imagecolorallocate($this->pic, 255, 255, 255);
  • $this->pic = imagerotate($this->pic, $deg, $white);
  • }
  • public function build() {
  • imageline ($this->pic, 0, $this->height/2, $this->width, $this->height/2, $this->lineclr);
  • imageellipse ($this->pic, $this->width/2, $this->height/2, 3.6*$this->scale, 3.6*$this->scale, $this->lineclr);
  • //DESSIN RAQUETTE HAUT
  • $col = imagecolorallocate($this->pic,100,10,10);
  • imagearc($this->pic, $this->width/2, 1.20*$this->scale, 13*$this->scale, 13*$this->scale, 0, 180, $this->lineclr);
  • imageline ($this->pic, ($this->width/2)-(6.50*$this->scale), 0, ($this->width/2)-(6.50*$this->scale), 1.20*$this->scale, $this->lineclr);
  • imageline ($this->pic, $this->width-(($this->width/2)-(6.50*$this->scale)), 0, $this->width-(($this->width/2)-(6.50*$this->scale)), 1.20*$this->scale, $this->lineclr);
  • imagefilledarc($this->pic, $this->width/2, 5.8*$this->scale, 3.6*$this->scale,3.6*$this->scale, 0, 180, $col, IMG_ARC_PIE);
  • imageline ($this->pic, ($this->width/2)-(1.8*$this->scale), 5.8*$this->scale, ($this->width/2)+(1.8*$this->scale), 5.8*$this->scale,$this->lineclr);
  • imageline ($this->pic, $this->width/2 - 3*$this->scale,0, $this->width/2 - 1.8*$this->scale, 5.8*$this->scale,$this->lineclr);
  • imageline ($this->pic, $this->width/2 + 3*$this->scale,0, $this->width/2 + 1.8*$this->scale, 5.8*$this->scale,$this->lineclr);
  • //DESSIN RAQUETTE BAS
  • imagearc($this->pic, $this->width/2,$this->height-1.20*$this->scale, 13*$this->scale, 13*$this->scale, 180, 0, $this->lineclr);
  • imageline ($this->pic, ($this->width/2)-(6.50*$this->scale), $this->height, ($this->width/2)-(6.50*$this->scale), $this->height-1.20*$this->scale, $this->lineclr);
  • imageline ($this->pic, $this->width-(($this->width/2)-(6.50*$this->scale)), $this->height, $this->width-(($this->width/2)-(6.50*$this->scale)), $this->height-1.20*$this->scale, $this->lineclr);
  • imagefilledarc($this->pic, $this->width/2, $this->height-5.8*$this->scale, 3.6*$this->scale,3.6*$this->scale, 180, 0, $col, IMG_ARC_PIE);
  • imageline ($this->pic, ($this->width/2)-(1.8*$this->scale), $this->height-5.8*$this->scale, ($this->width/2)+(1.8*$this->scale), $this->height-5.8*$this->scale,$this->lineclr);
  • imageline ($this->pic, $this->width/2 - 3*$this->scale,$this->height, $this->width/2 - 1.8*$this->scale, $this->height-5.8*$this->scale,$this->lineclr);
  • imageline ($this->pic, $this->width/2 + 3*$this->scale,$this->height, $this->width/2 + 1.8*$this->scale, $this->height-5.8*$this->scale,$this->lineclr);
  • imagefilltoborder ($this->pic, $this->width/2, 4*$this->scale,$this->bgcolor,$col);
  • //PANIER HAUT
  • $this->basketclr=imagecolorallocate($this->pic,0 ,0 ,0);
  • imageline ($this->pic, ($this->width/2)-(0.9*$this->scale), 1.2*$this->scale, ($this->width/2)+(0.9*$this->scale), 1.2*$this->scale,$this->basketclr);
  • imageline ($this->pic, $this->width/2, 0, $this->width/2, 1.2*$this->scale, $this->basketclr);
  • imageellipse ($this->pic, $this->width/2, 1.4*$this->scale, 0.4*$this->scale, 0.4*$this->scale, $this->basketclr);
  • //PANIER HAUT
  • $this->basketclr=imagecolorallocate($this->pic,0 ,0 ,0);
  • imageline ($this->pic, ($this->width/2)-(0.9*$this->scale), $this->height-1.2*$this->scale, ($this->width/2)+(0.9*$this->scale), $this->height-1.2*$this->scale,$this->basketclr);
  • imageline ($this->pic, $this->width/2, $this->height, $this->width/2, $this->height-1.2*$this->scale, $this->basketclr);
  • imageellipse ($this->pic, $this->width/2, $this->height-1.4*$this->scale, 0.4*$this->scale, 0.4*$this->scale, $this->basketclr);
  • }
  • }
  • $joueurs = array (0 => array( 'poste' => 'GB',
  • 'titulaire' => 1,
  • 'numero' => '1',
  • 'nom' => 'COUPET'),
  • 1 => array( 'poste' => 'ArCD',
  • 'titulaire' => 1,
  • 'numero' => '2',
  • 'nom' => 'THURAM'),
  • 2 => array( 'poste' => 'ArCG',
  • 'titulaire' => 1,
  • 'numero' => '5',
  • 'nom' => 'GALLAS'),
  • 3 => array( 'poste' => 'ArLD',
  • 'titulaire' => 1,
  • 'numero' => '15',
  • 'nom' => 'SAGNOL'),
  • 4 => array( 'poste' => 'ArLG',
  • 'titulaire' => 1,
  • 'numero' => '14',
  • 'nom' => 'REVEILLERE'),
  • 5 => array( 'poste' => 'MDC',
  • 'titulaire' => 1,
  • 'numero' => '4',
  • 'nom' => 'VIEIRA'),
  • 6 => array( 'poste' => 'MOD',
  • 'titulaire' => 1,
  • 'numero' => '6',
  • 'nom' => 'MAKELELE'),
  • 7 => array( 'poste' => 'MOG',
  • 'titulaire' => 1,
  • 'numero' => '10',
  • 'nom' => 'ZIDANE'),
  • 8 => array( 'poste' => 'AvD',
  • 'titulaire' => 1,
  • 'numero' => '8',
  • 'nom' => 'GIULY'),
  • 9 => array( 'poste' => 'AvG',
  • 'titulaire' => 1,
  • 'numero' => '12',
  • 'nom' => 'HENRY'),
  • 10 => array( 'poste' => 'AvCC',
  • 'titulaire' => 1,
  • 'numero' => '20',
  • 'nom' => 'TREZEGUET')
  • );
  • $adversaires = array (
  • 0 => array( 'poste' => 'GB',
  • 'titulaire' => 1,
  • 'numero' => '16',
  • 'nom' => 'BARTHEZ'),
  • 1 => array( 'poste' => 'ArCD',
  • 'titulaire' => 1,
  • 'numero' => '21',
  • 'nom' => 'BOUMSONG'),
  • 2 => array( 'poste' => 'ArCC',
  • 'titulaire' => 1,
  • 'numero' => '18',
  • 'nom' => 'MEXES'),
  • 3 => array( 'poste' => 'ArLD',
  • 'titulaire' => 1,
  • 'numero' => '19',
  • 'nom' => 'EVRA'),
  • 4 => array( 'poste' => 'ArCG',
  • 'titulaire' => 1,
  • 'numero' => '17',
  • 'nom' => 'MONTSOREAU'),
  • 5 => array( 'poste' => 'MDC',
  • 'titulaire' => 1,
  • 'numero' => '26',
  • 'nom' => 'DIARRA'),
  • 6 => array( 'poste' => 'MOD',
  • 'titulaire' => 1,
  • 'numero' => '7',
  • 'nom' => 'DHORASSO'),
  • 7 => array( 'poste' => 'MOG',
  • 'titulaire' => 1,
  • 'numero' => '22',
  • 'nom' => 'MICOUD'),
  • 8 => array( 'poste' => 'AvCD',
  • 'titulaire' => 1,
  • 'numero' => '13',
  • 'nom' => 'WILTORD'),
  • 9 => array( 'poste' => 'ArLG',
  • 'titulaire' => 1,
  • 'numero' => '23',
  • 'nom' => 'MALOUDA'),
  • 10 => array( 'poste' => 'AvCG',
  • 'titulaire' => 1,
  • 'numero' => '9',
  • 'nom' => 'SAHA')
  • );
  • try {
  • $terrain = new SOCCERGROUND(55,95,4);
  • $terrain->setname('images/terrain');
  • $terrain->build();
  • $terrain->display();
  • echo ' ';
  • $terrainmini = new SOCCERGROUND(45,90,4);
  • $terrainmini->setname('images/mini');
  • $terrainmini->build();
  • $terrainmini->display();
  • echo ' ';
  • //echo ('<br>');
  • $ext=new GRAPHDOMEXT ($joueurs,$adversaires,5);
  • $ext->settxtstyle (200,200,200,3);
  • $ext->setnumstyle (0,0,100,3);
  • $ext->build();
  • $ext->display();
  • //echo ('<br>');
  • $terrainmaxi = new SOCCERGROUND(90,120,4);
  • $terrainmaxi->setname('images/maxi');
  • $terrainmaxi->build();
  • $terrainmaxi->rotate(90);
  • $terrainmaxi->display();
  • $test = new BASKETGROUND(15,28,20);
  • $test -> setname('images/tmp');
  • $test->build();
  • $test->rotate(90);
  • //header ('Content-Type : image/png');
  • //$test->toscreen();
  • $test->display();
  • }
  • catch(Exception $e){
  • echo ($e->getMessage());
  • }
  • ?>
<?php

class IMGBASE {
  
  protected $width;
  protected $height;
  protected $bgcolor;     //RESSOURCE COLOR
  protected $pic;         //RESSOURCE IMAGE
  protected $format;
  protected $name;
  protected $extension;
  
  public function __construct ($pwidth=100, $pheight=100, $pR=245, $pG=245, $pB=245, $pformat='image/png'){
    
    $this->width = $pwidth;
    $this->height = $pheight;
    $this->format = $pformat;
    $this->name = 'tmp';
        
      if (!($this->pic = imagecreate ($this->width, $this->height))) 
        throw new Exception ('<font color ="red"><b>EXCEPTION ATTRAPEE :impossible de creer l\'image.</b></font>');
      if (($this->bgcolor = imagecolorallocate ($this->pic, $pR, $pG, $pB))===-1)
        throw new Exception ('<font color ="red"><b>EXCEPTION ATTRAPEE :Impossible d\'allouer une couleur de fond</b></font>');
  }
  
  public function setname ($name){
    $this->name = $name;
    
  }
  
  
  public function display() {
    $this->tofile();
    echo '<img src="'.$this->name.'.'.$this->extension.'">';
  }
  
  public function toscreen(){
    
    if (!$this->pic) throw new Exception ('Impossible d afficher l\'image');
    
    $a=array('image/jpeg'=>'imagejpeg', 'image/png'=>'imagepng', 'image/gif'=>'imagegif');
		$b=$a[$this->format];
		$b($this->pic);
    
  }
  
  public function tofile(){
    
    if (!is_dir(dirname( $this->name))) 
      throw new Exception ('Impossible de créer le fichier '.$this->name.' dans le répertoire '.dirname($this->name));
      
    $a=array('image/jpeg'=>'imagejpeg', 'image/png'=>'imagepng', 'image/gif'=>'imagegif');
		$b=$a[$this->format];
		$b($this->pic,$this->name.'.'.$this->extension);
    
    if ($this->pic)
          imagedestroy($this->pic);

  }  
}
class SOCCERGROUND extends IMGBASE {
    
    protected $scale ;//on multiplie la valeur en pixel par ce nombre pour avoir l'affichage 
    private $lineclr;// COULEUR DE LIGNE
    private $darkgrass;//ID COULEUR DE TONTE
    
    private function colorizegrass(){
      $this->darkgrass = imagecolorallocate ($this->pic, 0, 120, 0);
      for ($i=1 ; $i < 17 ; $i+=2){
        imagefilledrectangle ($this->pic, 0, $i*($this->height/16), $this->width, ($i+1)*($this->height/16), $this->darkgrass); 
      }
    }
    
    public function setscale ($sc){
      $this->scale=$sc;
    }
    
    public function __construct($w=70,$h=105,$sc=5){
      $this->scale = $sc;
      parent::__construct($w*$this->scale, $h*$this->scale, 0, 150, 0, 'image/png');
      $this->lineclr = imagecolorallocate ($this->pic, 255, 255, 255);
    }
    
    private function draw_mediane () {
      imageline($this->pic, 0, $this->height/2, $this->width, $this->height/2, $this->lineclr);
    }
    
    private function draw_medium_circle () {
      imageellipse ($this->pic, $this->width/2, $this->height/2, 18.3*$this->scale, 18.3*$this->scale, $this->lineclr);
      imagefilledellipse(
                  $this->pic,
                  $this->width/2,
                  $this->height/2,
                  5,
                  5,
                  $this->lineclr
                  );
    }
    
    private function draw_gk_zone () {
      $XUpMd = $this->width/2;
      $YUpMd = 0;
      $XDnMd = $this->width/2;
      $YDnMd = $this->height;
      //BUT DU HAUT
      imageline ( 
                $this->pic,
                $XUpMd-((7 * ($this->scale))/2), 
                $YUpMd ,
                $XUpMd-((7 * ($this->scale))/2),
                $YUpMd + 5,
                $this->lineclr
                );
      imageline ( 
                $this->pic,
                $XUpMd+((7 * ($this->scale))/2), 
                $YUpMd ,
                $XUpMd+((7 * ($this->scale))/2),
                $YUpMd + 5,
                $this->lineclr
                );
      //BUT DU BAS
      imageline ( 
                $this->pic,
                $XDnMd-((7 * ($this->scale))/2), 
                $YDnMd ,
                $XDnMd-((7 * ($this->scale))/2),
                $YDnMd - 10,
                $this->lineclr
                );
      imageline ( 
                $this->pic,
                $XDnMd+((7 * ($this->scale))/2), 
                $YDnMd ,
                $XDnMd+((7 * ($this->scale))/2),
                $YDnMd - 10,
                $this->lineclr
                );
      imageline ( 
                $this->pic,
                $XDnMd - ((7 * ($this->scale))/2), 
                $YDnMd - 10,
                $XDnMd + ((7 * ($this->scale))/2),
                $YDnMd - 10,
                $this->lineclr
                );
                
      //PETIT RECTANGLE BUT DU BAS 
      imageline (
                $this->pic,
                $XDnMd - (9 * $this->scale),
                $YDnMd,
                $XDnMd - (9 * $this->scale),
                $YDnMd - (5.5 * $this->scale),
                $this->lineclr
                );
      imageline (
                $this->pic,
                $XDnMd + (9 * $this->scale),
                $YDnMd,
                $XDnMd + (9 * $this->scale),
                $YDnMd - (5.5 * $this->scale),
                $this->lineclr
                );
      imageline (
                $this->pic,
                $XDnMd - (9 * $this->scale),
                $YDnMd - (5.5 * $this->scale),
                $XDnMd + (9 * $this->scale),
                $YDnMd - (5.5 * $this->scale),
                $this->lineclr
                );
                
      //PETIT RECTANGLE BUT DU HAUT
      imageline (
                $this->pic,
                $XUpMd - (9 * $this->scale),
                $YUpMd,
                $XUpMd - (9 * $this->scale),
                $YUpMd + (5.5 * $this->scale),
                $this->lineclr
                );
      imageline (
                $this->pic,
                $XUpMd + (9 * $this->scale),
                $YUpMd,
                $XUpMd + (9 * $this->scale),
                $YUpMd + (5.5 * $this->scale),
                $this->lineclr
                );
      imageline (
                $this->pic,
                $XUpMd - (9 * $this->scale),
                $YUpMd + (5.5 * $this->scale),
                $XUpMd + (9 * $this->scale),
                $YUpMd + (5.5 * $this->scale),
                $this->lineclr
                );
      //POINT PENALTY DU HAUT
      imagefilledellipse(
                  $this->pic,
                  $XUpMd,
                  11 * $this->scale,
                  5,
                  5,
                  $this->lineclr
                  );
      //POINT PENALTY DU BAS
      imagefilledellipse(
                  $this->pic,
                  $XDnMd,
                  $YDnMd-(11 * $this->scale),
                  5,
                  5,
                  $this->lineclr
                  );
      //SURFACE DU HAUT
      imageline (
                $this->pic,
                $XUpMd - (20*$this->scale),
                0,
                $XUpMd - (20*$this->scale),
                16.5 * $this->scale,
                $this->lineclr
                );
      imageline (
                $this->pic,
                $XUpMd + (20*$this->scale),
                0,
                $XUpMd + (20*$this->scale),
                16.5 * $this->scale,
                $this->lineclr
                );
      imageline (
                $this->pic,
                $XUpMd - (20*$this->scale),
                16.5 * $this->scale,
                $XUpMd + (20*$this->scale),
                16.5 * $this->scale,
                $this->lineclr
                );
      //SURFACE DU BAS
      imageline (
                $this->pic,
                $XDnMd - (20*$this->scale),
                $YDnMd,
                $XDnMd - (20*$this->scale),
                $YDnMd - (16.5 * $this->scale),
                $this->lineclr
                );
      imageline (
                $this->pic,
                $XDnMd + (20*$this->scale),
                $YDnMd,
                $XDnMd + (20*$this->scale),
                $YDnMd - (16.5 * $this->scale),
                $this->lineclr
                );
      imageline (
                $this->pic,
                $XDnMd - (20*$this->scale),
                $YDnMd - (16.5 * $this->scale),
                $XDnMd + (20*$this->scale),
                $YDnMd - (16.5 * $this->scale),
                $this->lineclr
                );
      
      //ARC BAS
      imagearc(
                $this->pic,
                $XDnMd,
                $YDnMd-(11 * $this->scale),
                18.3 * $this->scale,
                18.3 * $this->scale,
                180+36.95,
                -36.95,
                $this->lineclr
                );
      //ARC HAUT
      imagearc(
                $this->pic,
                $XUpMd,
                11 * $this->scale,
                18.3 * $this->scale,
                18.3 * $this->scale,
                +36.95,
                180-36.95,
                $this->lineclr
                );
    }
    
    public function rotate($deg){
      $white = imagecolorallocate($this->pic, 255, 255, 255);
      $this->pic = imagerotate($this->pic, $deg, $white);
    }
    
    public function build (){
      $this->colorizegrass();
      $this->draw_mediane();
      $this->draw_medium_circle();
      $this->draw_gk_zone ();
    }

}

class COMPOSITIONGRAPH extends SOCCERGROUND{
  
  private $team = array();
  protected $txtcolor;
  protected $fontsize;
  protected $numcolor; 
  protected $numsize;
  protected $font;
  
  public function __construct($tm=NULL,$psc=5){
    parent::__construct(70,105,$psc);
    if (isset($tm)&&is_array($tm) ){
      $this->team = $tm;
      //echo $tm[0]['poste'];
    }else  throw new Exception('ERREUR DANS LE TABLEAU team');
    $this->txtcolor = imagecolorallocate ($this->pic, 0, 0, 200);
    $this->numcolor = imagecolorallocate ($this->pic, 255, 0, 0);
    $this->fontsize = 3;
    $this->numsize = 4;
  }
  
 /* public function rotate180(){
    $this->pic=imagerotate($this->pic,180,0);
  }*/
  
  public function settxtstyle($R,$G,$B,$sz){
    
    $this->txtcolor = imagecolorallocate ($this->pic, $R, $G, $B);
    $this->fontsize = $sz;
  
  }
  
   public function setnumstyle($R,$G,$B,$sz){
    
    $this->numcolor = imagecolorallocate ($this->pic, $R, $G, $B);
    $this->numsize = $sz;
    
  }
  
  private function incrust_player ( $cx, $cy, $name, $num){
    $textwidth = (strlen($name)*($this->fontsize+4))/2;
    $numwidth = (strlen($num)*($this->numsize+4))/2;
    imagestring(
                $this->pic,
                $this->fontsize,
                $cx - $textwidth,
                $cy,
                $name,
                $this->txtcolor);
    imagestring(
                $this->pic,
                $this->numsize,
                $cx-$numwidth,
                $cy + 12,
                $num,
                $this->numcolor);
  }
  
  protected function writeongraph ($location='UP'){
    if ( (isset($this->team)&& is_array($this->team)) ){
      $n = count ($this->team);
      for( $i=0 ; $i < $n ; $i++){
        switch ($this->team[$i]['poste']){
          case 'GB':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( ($this->width/2), 7*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else
                $this->incrust_player ( ($this->width/2),$this->height-(11*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
                
            }
            break;
          case 'ArCD':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( 2*($this->width/6), 21*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else $this->incrust_player ( 4*($this->width/6),$this->height-(25*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
            }
            break;
          case 'ArCG':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( 4*($this->width/6), 21*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else $this->incrust_player ( 2*($this->width/6),$this->height-(25*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
            }
            break;
          case 'ArCC':
           if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( ($this->width/2), 21*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else
                $this->incrust_player ( ($this->width/2), $this->height-(25*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
                
            }
            break;
          case 'ArLD':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( ($this->width/7), 30*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else $this->incrust_player ( 6*($this->width/7), $this->height-(35*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
            }
            break;
          case 'ArLG':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( 6*($this->width/7), 30*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else $this->incrust_player ( ($this->width/7), $this->height-(35*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
                
            }
            break;
          case 'MDC':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( $this->width/2, 35*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else 
                $this->incrust_player ( $this->width/2, $this->height - (40*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
            }
            break;
          case 'MDD':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( $this->width/3, 35*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else 
                $this->incrust_player ( 2*($this->width/3), $this->height - (40*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
            }
            break;
          case 'MDG':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( 2*($this->width/3), 35*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else
                $this->incrust_player ( ($this->width/3), $this->height - (40*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
            }
            break;
          case 'MOD':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( $this->width/3, 40*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else
                $this->incrust_player ( 2*($this->width/3), $this->height - (50*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
            }
            break;
          case 'MOG':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( 2*($this->width/3), 40*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else  
                $this->incrust_player (($this->width/3), $this->height - (50*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
            }
            break;
          case 'MOC':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( $this->width/2, 40*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else
                $this->incrust_player ( $this->width/2, $this->height - (50*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
            }
            break;
          case 'AvD':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( $this->width/6, 55*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else
                $this->incrust_player ( 5*($this->width/6), $this->height - (60*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
            }
            break;
          case 'AvG':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( 5*($this->width/6), 55*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else
                $this->incrust_player ( ($this->width/6), $this->height - (60*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
            }
            break;
          case 'AvCD':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( $this->width/3, 55*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else
                $this->incrust_player ( 2*($this->width/3), $this->height - (60*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
            }
            break;
          case 'AvCG':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( 2*($this->width/3), 55*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else
                $this->incrust_player ( ($this->width/3), $this->height - (60*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
            }
            break;
          case 'AvCC':
            if ($this->team[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( $this->width/2, 55*$this->scale, $this->team[$i]['nom'], $this->team[$i]['numero']);
              else
                $this->incrust_player ( $this->width/2, $this->height - (60*$this->scale), $this->team[$i]['nom'], $this->team[$i]['numero']);
            }
            break;
        }
      }
    }
    else throw new Exception ('ERREUR DANS LE TABLEAU team');
  }
   
  public function build($location='UP') {
    parent::build();
    $this->writeongraph($location);
  }
  
}

class GRAPHDOMEXT extends COMPOSITIONGRAPH {
  
  private $teamext;
  private $colorext;
  private $numcolorext;
  
  public function __construct($tabdom, $tabext, $sc=5) {
    parent::__construct($tabdom, $sc);
    $this->teamext=$tabext;
    $this->colorext = imagecolorallocate($this->pic,0,0,120);
    $this->numcolorext = imagecolorallocate($this->pic,120,0,0);
  }
  
  private function incrust_player ( $cx, $cy, $name, $num){
    $textwidth = (strlen($name)*($this->fontsize+4))/2;
    $numwidth = (strlen($num)*($this->numsize+4))/2;
    imagestring(
                $this->pic,
                $this->fontsize,
                $cx - $textwidth,
                $cy,
                $name,
                $this->colorext);
    imagestring(
                $this->pic,
                $this->numsize,
                $cx-$numwidth,
                $cy + 12,
                $num,
                $this->numcolorext);
  }
  
  public function build($location='UP') {
    parent::build();
    $this->writeongraph($location);
    $this->addteamextongraph();
  }
  
  public function addteamextongraph ($location='DOWN'){
    if ( (isset($this->teamext)&& is_array($this->teamext)) ){
      $n = count ($this->teamext);
      for( $i=0 ; $i < $n ; $i++){
        switch ($this->teamext[$i]['poste']){
          case 'GB':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( ($this->width/2), 7*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else
                $this->incrust_player ( ($this->width/2),$this->height-(11*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
                
            }
            break;
          case 'ArCD':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( 2*($this->width/6), 21*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else $this->incrust_player ( 4*($this->width/6),$this->height-(25*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
            }
            break;
          case 'ArCG':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( 4*($this->width/6), 21*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else $this->incrust_player ( 2*($this->width/6),$this->height-(25*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
            }
            break;
          case 'ArCC':
           if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( ($this->width/2), 21*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else
                $this->incrust_player ( ($this->width/2), $this->height-(25*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
                
            }
            break;
          case 'ArLD':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( ($this->width/7), 30*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else $this->incrust_player ( 6*($this->width/7), $this->height-(35*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
            }
            break;
          case 'ArLG':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( 6*($this->width/7), 30*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else $this->incrust_player ( ($this->width/7), $this->height-(35*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
                
            }
            break;
          case 'MDC':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( $this->width/2, 35*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else 
                $this->incrust_player ( $this->width/2, $this->height - (40*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
            }
            break;
          case 'MDD':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( $this->width/3, 35*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else 
                $this->incrust_player ( 2*($this->width/3), $this->height - (40*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
            }
            break;
          case 'MDG':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( 2*($this->width/3), 35*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else
                $this->incrust_player ( ($this->width/3), $this->height - (40*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
            }
            break;
          case 'MOD':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( $this->width/3, 45*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else
                $this->incrust_player ( 2*($this->width/3), $this->height - (45*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
            }
            break;
          case 'MOG':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( 2*($this->width/3), 45*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else  
                $this->incrust_player (($this->width/3), $this->height - (45*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
            }
           break;
          case 'MOC':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( $this->width/2, 45*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else
                $this->incrust_player ( $this->width/2, $this->height - (45*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
            }
            break;
          case 'AvD':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( $this->width/6, 55*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else
                $this->incrust_player ( 5*($this->width/6), $this->height - (60*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
            }
            break;
          case 'AvG':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( 5*($this->width/6), 55*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else
                $this->incrust_player ( ($this->width/6), $this->height - (60*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
            }
            break;
          case 'AvCD':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( $this->width/3, 55*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else
                $this->incrust_player ( 2*($this->width/3), $this->height - (60*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
            }
            break;
          case 'AvCG':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( 2*($this->width/3), 55*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else
                $this->incrust_player ( ($this->width/3), $this->height - (60*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
            }
            break;
          case 'AvCC':
            if ($this->teamext[$i]['titulaire']){
              if ($location=='UP')
                $this->incrust_player ( $this->width/2, 55*$this->scale, $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
              else
                $this->incrust_player ( $this->width/2, $this->height - (60*$this->scale), $this->teamext[$i]['nom'], $this->teamext[$i]['numero']);
            }
            break;
        }
      }
    }
    else throw new Exception('ERREUR DANS LE TABLEAU teamext');
  }
}

class BASKETGROUND extends IMGBASE{
	
	protected $scale;
	private $lineclr;// COULEUR DE LIGNE
	private $basketclr;

	
	public function __construct($w=15,$h=28,$sc=20){
      
      $this->scale = $sc;
      parent::__construct($w*$this->scale, $h*$this->scale, 228, 202, 152, 'image/png');
      //$this->bgcolor1 = imagecolorallocate ($this->pic ,228,202,152);
      $this->lineclr = imagecolorallocate ($this->pic, 255, 255, 255);
    
    }
  public function rotate ($deg) {
  	$white = imagecolorallocate($this->pic, 255, 255, 255);
    $this->pic = imagerotate($this->pic, $deg, $white);
  }
  public function build() {
  	imageline ($this->pic, 0, $this->height/2, $this->width, $this->height/2, $this->lineclr);
  	imageellipse ($this->pic, $this->width/2, $this->height/2, 3.6*$this->scale, 3.6*$this->scale, $this->lineclr);
  	//DESSIN RAQUETTE HAUT
  	$col = imagecolorallocate($this->pic,100,10,10);
  	imagearc($this->pic, $this->width/2, 1.20*$this->scale, 13*$this->scale, 13*$this->scale, 0, 180, $this->lineclr);
  	imageline ($this->pic, ($this->width/2)-(6.50*$this->scale), 0, ($this->width/2)-(6.50*$this->scale), 1.20*$this->scale, $this->lineclr);
  	imageline ($this->pic, $this->width-(($this->width/2)-(6.50*$this->scale)), 0, $this->width-(($this->width/2)-(6.50*$this->scale)), 1.20*$this->scale, $this->lineclr);
  	imagefilledarc($this->pic, $this->width/2, 5.8*$this->scale, 3.6*$this->scale,3.6*$this->scale, 0, 180,  $col, IMG_ARC_PIE);
  	imageline ($this->pic, ($this->width/2)-(1.8*$this->scale), 5.8*$this->scale, ($this->width/2)+(1.8*$this->scale), 5.8*$this->scale,$this->lineclr);
  	imageline ($this->pic, $this->width/2 - 3*$this->scale,0, $this->width/2 - 1.8*$this->scale, 5.8*$this->scale,$this->lineclr);
  	imageline ($this->pic, $this->width/2 + 3*$this->scale,0, $this->width/2 + 1.8*$this->scale, 5.8*$this->scale,$this->lineclr);
  	
  	//DESSIN RAQUETTE BAS
  	
  	imagearc($this->pic, $this->width/2,$this->height-1.20*$this->scale, 13*$this->scale, 13*$this->scale, 180, 0, $this->lineclr);
  	imageline ($this->pic, ($this->width/2)-(6.50*$this->scale), $this->height, ($this->width/2)-(6.50*$this->scale), $this->height-1.20*$this->scale, $this->lineclr);
  	imageline ($this->pic, $this->width-(($this->width/2)-(6.50*$this->scale)), $this->height, $this->width-(($this->width/2)-(6.50*$this->scale)), $this->height-1.20*$this->scale, $this->lineclr);
  	imagefilledarc($this->pic, $this->width/2, $this->height-5.8*$this->scale, 3.6*$this->scale,3.6*$this->scale, 180, 0, $col, IMG_ARC_PIE);
  	imageline ($this->pic, ($this->width/2)-(1.8*$this->scale), $this->height-5.8*$this->scale, ($this->width/2)+(1.8*$this->scale), $this->height-5.8*$this->scale,$this->lineclr);
  	imageline ($this->pic, $this->width/2 - 3*$this->scale,$this->height, $this->width/2 - 1.8*$this->scale, $this->height-5.8*$this->scale,$this->lineclr);
  	imageline ($this->pic, $this->width/2 + 3*$this->scale,$this->height, $this->width/2 + 1.8*$this->scale, $this->height-5.8*$this->scale,$this->lineclr);
  	
  	
  	imagefilltoborder ($this->pic, $this->width/2, 4*$this->scale,$this->bgcolor,$col);
  	//PANIER HAUT
  	$this->basketclr=imagecolorallocate($this->pic,0 ,0 ,0);
  	imageline ($this->pic, ($this->width/2)-(0.9*$this->scale), 1.2*$this->scale, ($this->width/2)+(0.9*$this->scale), 1.2*$this->scale,$this->basketclr);
  	imageline ($this->pic, $this->width/2, 0, $this->width/2, 1.2*$this->scale, $this->basketclr);
  	imageellipse ($this->pic, $this->width/2, 1.4*$this->scale, 0.4*$this->scale, 0.4*$this->scale, $this->basketclr); 
 		//PANIER HAUT
  	$this->basketclr=imagecolorallocate($this->pic,0 ,0 ,0);
  	imageline ($this->pic, ($this->width/2)-(0.9*$this->scale), $this->height-1.2*$this->scale, ($this->width/2)+(0.9*$this->scale), $this->height-1.2*$this->scale,$this->basketclr);
  	imageline ($this->pic, $this->width/2, $this->height, $this->width/2, $this->height-1.2*$this->scale, $this->basketclr);
  	imageellipse ($this->pic, $this->width/2, $this->height-1.4*$this->scale, 0.4*$this->scale, 0.4*$this->scale, $this->basketclr); 
 		 	
  }
	
}

$joueurs = array (0 => array( 'poste' => 'GB', 
                              'titulaire' => 1, 
                              'numero' => '1', 
                              'nom' => 'COUPET'),
                  1 => array( 'poste' => 'ArCD',
                              'titulaire' => 1, 
                              'numero' => '2', 
                              'nom' => 'THURAM'),
                  2 => array( 'poste' => 'ArCG',
                              'titulaire' => 1, 
                              'numero' => '5', 
                              'nom' => 'GALLAS'),
                  3 => array( 'poste' => 'ArLD',
                              'titulaire' => 1, 
                              'numero' => '15', 
                              'nom' => 'SAGNOL'),
                  4 => array( 'poste' => 'ArLG',
                              'titulaire' => 1, 
                              'numero' => '14', 
                              'nom' => 'REVEILLERE'),
                  5 => array( 'poste' => 'MDC',
                              'titulaire' => 1, 
                              'numero' => '4', 
                              'nom' => 'VIEIRA'),
                  6 => array( 'poste' => 'MOD',
                              'titulaire' => 1, 
                              'numero' => '6', 
                              'nom' => 'MAKELELE'),
                  7 => array( 'poste' => 'MOG',
                              'titulaire' => 1, 
                              'numero' => '10', 
                              'nom' => 'ZIDANE'),
                  8 => array( 'poste' => 'AvD',
                              'titulaire' => 1, 
                              'numero' => '8', 
                              'nom' => 'GIULY'),
                  9 => array( 'poste' => 'AvG',
                              'titulaire' => 1, 
                              'numero' => '12', 
                              'nom' => 'HENRY'),
                  10 => array( 'poste' => 'AvCC',
                              'titulaire' => 1, 
                              'numero' => '20', 
                              'nom' => 'TREZEGUET')                                                                                          
                  ); 
                  
$adversaires = array (
                  0 => array( 'poste' => 'GB', 
                              'titulaire' => 1, 
                              'numero' => '16', 
                              'nom' => 'BARTHEZ'),
                  1 => array( 'poste' => 'ArCD',
                              'titulaire' => 1, 
                              'numero' => '21', 
                              'nom' => 'BOUMSONG'),
                  2 => array( 'poste' => 'ArCC',
                              'titulaire' => 1, 
                              'numero' => '18', 
                              'nom' => 'MEXES'),
                  3 => array( 'poste' => 'ArLD',
                              'titulaire' => 1, 
                              'numero' => '19', 
                              'nom' => 'EVRA'),
                  4 => array( 'poste' => 'ArCG',
                              'titulaire' => 1, 
                              'numero' => '17', 
                              'nom' => 'MONTSOREAU'),
                  5 => array( 'poste' => 'MDC',
                              'titulaire' => 1, 
                              'numero' => '26', 
                              'nom' => 'DIARRA'),
                  6 => array( 'poste' => 'MOD',
                              'titulaire' => 1, 
                              'numero' => '7', 
                              'nom' => 'DHORASSO'),
                  7 => array( 'poste' => 'MOG',
                              'titulaire' => 1, 
                              'numero' => '22', 
                              'nom' => 'MICOUD'),
                  8 => array( 'poste' => 'AvCD',
                              'titulaire' => 1, 
                              'numero' => '13', 
                              'nom' => 'WILTORD'),
                  9 => array( 'poste' => 'ArLG',
                              'titulaire' => 1, 
                              'numero' => '23', 
                              'nom' => 'MALOUDA'),
                  10 => array( 'poste' => 'AvCG',
                              'titulaire' => 1, 
                              'numero' => '9', 
                              'nom' => 'SAHA')                                                                                          
                  ); 
 

try {
  $terrain = new SOCCERGROUND(55,95,4);
  $terrain->setname('images/terrain');
  $terrain->build();
  $terrain->display();
  echo ' ';
  $terrainmini = new SOCCERGROUND(45,90,4);
  $terrainmini->setname('images/mini');
  $terrainmini->build();
  $terrainmini->display();
  echo ' ';
  //echo ('<br>');
  $ext=new GRAPHDOMEXT ($joueurs,$adversaires,5);
  $ext->settxtstyle (200,200,200,3);
  $ext->setnumstyle (0,0,100,3);
  $ext->build();
  $ext->display();
  //echo ('<br>');
  $terrainmaxi = new SOCCERGROUND(90,120,4);
  $terrainmaxi->setname('images/maxi');
  $terrainmaxi->build();
  
  $terrainmaxi->rotate(90);
  $terrainmaxi->display();
  $test = new BASKETGROUND(15,28,20);
  $test -> setname('images/tmp');
  $test->build();
  $test->rotate(90);
  //header ('Content-Type : image/png');
  //$test->toscreen();
  $test->display();
}
catch(Exception $e){
  echo ($e->getMessage());
}

?>

 Conclusion

Ces classes sans prétentions peuvent être utiles aux webmasters et développeurs de sites dédiés au sport.

On peut gérer l'echelle du terrain en passant dans le constructeur l'echelle (scale) en parametre lors de l'appel avec new.
Voir exemple en bas du script (5 par défaut = multiplie les dimensions par 5).
Les terrains sont dessinés suivant les normes officielles des fédérations internationales.



 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Historique

12 février 2006 14:37:22 :
Petites rectifs suite aux remarques de FhX et coucou747 (gestion des erreurs). MODIFS : AJOUT d'une classe pour créer la composition de 2 équipes s'affrontant AJOUT d'une classe pour creer un terrain de basket .(BASKETGROUND).
12 février 2006 21:13:12 :
Mise en ligne du zip pour les flémards qui n'aiment pas le copier-coller :-)
13 février 2006 20:10:28 :
remplacement switch

 Sources du même auteur

CLASSE FEUILLE DE TEMPS PHP5
PHP 5 CLASSES DE REDIRECTION DES EXCEPTIONS DANS UN SYSTÈME...
[PHP5]AUTHENTICATION MANAGER
Source avec Zip Source avec une capture PHP 5 CLASSE CALENDRIER QUI RENVOIE LA DATE CLIQUÉE DANS 1 É...
Source avec Zip Source avec une capture PHP5 CLASSE ARBRE INVERSÉ (HUFFMAN) COMPRESSION DECOMPRESSIO...

 Sources de la même categorie

Source avec Zip GÉNÉRATION AUTOMATIQUE DE FICHIER .CLASS.PHP EN FONCTION D'U... par ig3
CLASSE D'OBJET DE CRYPTAGE ET DÉCRYPTAGE DE CHAINES DE CARAC... par 8Tnerolf8
Source avec Zip MY.DEVIANTART API par inwebo
CLASSE DE GESTION DE "VARIABLES GLOBALES D'ENVIRONNEMENT" par pifou25
Source avec Zip COLLECTION.CLASS.MIN.PHP par thunderhunter

 Sources en rapport avec celle ci

SYSTÈME DE PAGINATION AVEC BDD ET IMAGES (FICHIERS) par begueradj
Source avec Zip CLASSE DE REDIMENSIONNEMENT D'IMAGES PHP par beejeridou
Source avec Zip CODE POUR HÉBERGEUR D'IMAGE par bonhommecrea
Source avec Zip Source avec une capture MY.PICS : TRAITEMENT D'IMAGES NON DESTRUCTIF par inwebo
Source avec Zip FUNCTION IMAGE SIMPLE ET ARRAY par astro53

Commentaires et avis

Commentaire de FhX le 11/02/2006 14:04:37

Un try catch dans le constructeur ... beurk :)
Faut faire ca "hors classe" !

try {
$objet = new object;
} catch (Exception $e) {
   echo $e->getmessage();
}

Mais pas dans la classe elle-même, ca n'a aucun interet ! :)

Commentaire de coucou747 le 11/02/2006 17:17:57 administrateur CS

il y a d'autres choses dégeulasses...

if (!($this->pic = @imagecreate ($this->width, $this->height)))


on ne masque pas une erreur, on la prévoit...

Commentaire de guill76 le 11/02/2006 17:38:17

Ouais, OK
En fait, je commence juste à utiliser la gestion des erreurs par exception, donc j'y vais un peu à tatons .
Mais j'en prends notes.
Merci.  

Commentaire de guill76 le 12/02/2006 15:06:21

Une petite chose pour ceux qui vont exécuter ce script :
il faut créer un répertoire nommé images dans le répertoire d'exécution pour ne pas avoir d'erreurs.
Et il faut biensur avoir l'extension gd d'intégrée à php.

Commentaire de coucou747 le 12/02/2006 17:17:14 administrateur CS

#
# switch($this->format){
# case 'image/jpeg':
# imagejpeg ($this->pic);
# break;
# case 'image/png':
# imagepng($this->pic);
# break;
# case 'image/gif':
# imagegif($this->pic);
# break;
# }
# }

pour ça, tu peux utiliser les $$...

Commentaire de alpha386 le 12/02/2006 17:25:49

Salut

J'aimerais bien que le fichier soit en zip. Cela me tente pas d'effacer 911 ligne de 3 caractères soit 2733 fois la touche delete.

Commentaire de guill76 le 12/02/2006 20:38:10

Qu'entends tu par $$ coucou ?
ça m'interesse ton astuce mais je connais pas du tout???

Commentaire de guill76 le 12/02/2006 20:41:10

Pour alpha, moi je l'ai testé et t'es vraiment pas obligé de copier les numéros de ligne avec le code à moins que tu aie firefox (ou là effectivement c'est plus dur).  

Commentaire de malalam le 13/02/2006 10:18:42 administrateur CS

Guill76 => $$ : http://fr2.php.net/manual/fr/language.variables.variable.php

Commentaire de guill76 le 13/02/2006 18:23:09

Oui j'avais effectivement vu mais, je vois pas bien en quoi ici cela peut m'être utile et comment l'utiliser dans mon cas?  

Commentaire de coucou747 le 13/02/2006 18:48:40 administrateur CS

$a=array('image/jpeg'=>'imagejpeg', 'image/png'=>'imagepng', 'image/gif'=>'imagegif');
$$a($this->pic);

Commentaire de guill76 le 13/02/2006 19:31:41

Ca n'a pas l'air de marcher avec les fonctions:
J'ai essayé vomme ça  
$a=array('image/jpeg'=>'imagejpeg', 'image/png'=>'imagepng', 'image/gif'=>'imagegif');
$b=$a[$this->format];
$$b.='('.$this->pic.')';
Résultat:
Notice: Undefined variable: imagepng in D:\Program Files\Apache Group\Apache2\www\proj\php\classes\graphism\IMG.php on line 60

Commentaire de guill76 le 13/02/2006 19:37:43

puis comme ça (ça m'avait l'air plus correct):
$b=$a[$this->format].'('.$this->pic.')';
$$b;
et cette erreur:
Notice: Undefined variable: imagepng(Resource id #6) in D:\Program Files\Apache Group\Apache2\www\proj\php\classes\graphism\IMG.php on line 60

Commentaire de coucou747 le 13/02/2006 19:42:47 administrateur CS

oulala oui...
$b=$a[$this->format];


$b($this->pic);

Commentaire de guill76 le 13/02/2006 19:53:24

OK c'est plutôt génial ton truc .
merci.

Commentaire de barbaralille le 12/06/2006 07:04:22

sympa cette source merci

Commentaire de papamonchichi le 12/01/2009 10:34:58

Bonjour,

je suis a la recherche d'une application facebook ou un petit logiciel a partager avec des amis pour faire des composition d'equipe de foot.
La compo devrait etre faite avec les données de mes amis avec qui je joue. Chaque semaine on devrait pouvoir donner sa compo.
Diverse données comme le nom, la photo, specialité etc des joueurs devrait pouvoir etre accesible a tous ainsi que la formation utilisée.
J'ai bien vu votre poste mais comme je ne suis pas callé en informatique je n'y comprends rien et je ne sais meme pas comment faire pour voir le resultat (en image) des codes que vous avez posté.
Je me dis que je ne doit pas etre le premier a vouloir faire ce truc donc peut-etre qu'il est possible de telecharger les codes deja existant sur ce site?
Je vous remercie d'avance pour votre reponse,
BAV
Serge

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

génération d'une page php par php [ par Vapula ] Bonjour à tousJe souhaiterais générer une page php grâce à une fonction php , mais le problème est que la fonction envoie bien le code html, et php SA Préchargement d'images [ par fgerm76 ] Bonjour à tous,pour que l'affichage de mon calque soit instantané, j'ai besoin de précharger les images le composant.Et ensuite d'affecter ces images g l'adresse d'une images qui est contenu dans le chjamps d'une table et ... [ par Ethan00000 ] je programme en php et je debute si tu sais m'aider ce serais sympa.j'ai une base de données dans laquelle j'ai une table qui contient un champs "imag MySQL et images [ par Marneus Calgar ] SalutJ'aimerais savoir s'il est possible de stocker des images dans une table MySQL et d'y accéder depuis une page PHP. En fait, je voudrais faire un MySQL et images [ par Marneus Calgar ] SalutJ'aimerais savoir s'il est possible de stocker des images dans une table MySQL et d'y accéder depuis une page PHP. En fait, je voudrais faire un Lecture d'un dossier... [ par RockmanX ] Voila mon "problème":Dans le dossier ci-dessous, il y a des images nommées:smile1.gif,smile2.gif,...smile8.gifj''ai écrit le script ci-dessous mais au Inclure a partir d'un rep different [ par fabiin ] Salutavoir voila mon problème:J'ai un fichier/dossier/monfichier.phpki inclu une page /page.phpet dans cette page il y a une image /images/machin.gifO des images dans un tablo !!! [ par penchaki ] voilà j'ai des images, avec des titres, que j'ai mise dans une base donnée ... jusque là pas de problémepar contre je voudrais les afficher en lignes upload d'images [ par psychodingue ] salut tout le monde,moi j'ai un gros prob.J'ai fait un site pour une entreprise qui vend du matos info, et donc dedant y'a une administration pour ajo Vérifier l'extention l'ors d'uppload [ par BirD ] Hello, je suis en train de faire un site avec lequel on peut upploader des images. Je veux fair un test afin que ce qu'on uppload soit bien des images


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,030 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales