begin process at 2010 03 21 23:16:20
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Graphique

 > UN CAMEMBERT ET UN EN 3D ET ÉCLATÉ

UN CAMEMBERT ET UN EN 3D ET ÉCLATÉ


 Information sur la source

Note :
6,71 / 10 - par 7 personnes
6,71 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Graphique Niveau :Initié Date de création :29/03/2005 Date de mise à jour :26/07/2005 10:15:06 Vu / téléchargé :6 743 / 870

Auteur : lefter

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

 Description

Cliquez pour voir la capture en taille normale
Code source d'une classe permettant de créer simplement un camembert en 3D!
Voilà, quelque explication!

Source

  • // Pour l'utiliser, on l'appel
  • include 'cam.php';
  • // On crée l'objet
  • $Cam=new GraphicQuart;
  • // On dimensionne le camembert
  • // 'Titre' , Largueur , Hauteur , éclatement X , éclatement Y
  • $Cam->CreerQuart('Titre',200,100,0,0,9);
  • // On ajoute le premier quart
  • // la valeur 9 , et le titre du quart 'Premier quart'
  • $Cam->AjouterQuart(9,'Premier quart');
  • // On change la couleur du premier quartier
  • $Cam->SetColor(1,"FFE07F");
  • // Puis le deuxième
  • $Cam->AjouterQuart(7,'Deuxième quart');
  • // Le troisième
  • $Cam->AjouterQuart(2,'Troisième quart');
  • // Le quatrième
  • $Cam->AjouterQuart(11,'Quatrième quart');
  • // Et on dessine en incluant la légende
  • $Cam->Draw('camembert.png');
// Pour l'utiliser, on l'appel
include 'cam.php';
// On crée l'objet
$Cam=new GraphicQuart;
// On dimensionne le camembert
// 'Titre' , Largueur , Hauteur , éclatement X , éclatement Y
$Cam->CreerQuart('Titre',200,100,0,0,9);
// On ajoute le premier quart 
// la valeur 9 , et le titre du quart 'Premier quart'
$Cam->AjouterQuart(9,'Premier quart');
// On change la couleur du premier quartier
$Cam->SetColor(1,"FFE07F");
// Puis le deuxième
$Cam->AjouterQuart(7,'Deuxième quart');
// Le troisième
$Cam->AjouterQuart(2,'Troisième quart');
// Le quatrième
$Cam->AjouterQuart(11,'Quatrième quart');
// Et on dessine en incluant la légende
$Cam->Draw('camembert.png');

 Conclusion

C'est une version si vous trouvé un bugs signalé le moi ! Merci!
Il marche très bien sur Linux

 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

29 mars 2005 21:43:06 :
30 mars 2005 18:58:40 :
30 mars 2005 19:05:13 :
30 mars 2005 19:14:56 :
30 mars 2005 21:34:36 :
30 mars 2005 21:42:38 :
26 juillet 2005 10:15:06 :
Correction des bugs d'affichage des quartiers et corrections du code HTML

 Sources du même auteur

Source avec Zip UN FICHIER EXCEL EST UN!

 Sources de la même categorie

Source avec une capture DES HISTOGRAMES , CAMEMBERT 3D ET ÉCLATÉS CRÉÉ AU VOL EN PH... par zozo14
AJOUTER UN ARRIÈRE PLAN SUR UNE IMAGE par digitaldax
REDIMENSIONNER UNE IMAGE EN PHP par digitaldax
Source avec Zip RECHERCHE DE MOTIF DANS UNE IMAGE par ParseError
BARRES PARAMÉTRABLES EN DÉGRADÉ DE COULEUR ET AVEC TEXTE DA... par hornetbzz

Commentaires et avis

Commentaire de GRenard le 30/03/2005 02:45:10

Un screenshot, une explication de comment ca fonctionne, passer <? par <?php, ne pas mettre de code html dans une si belle classe serait apprécié !
http://www.phpcs.com/code.aspx?id=24870

Commentaire de Kirua le 30/03/2005 08:16:02

viite, un screenshot !

Commentaire de willinfeo le 30/03/2005 15:08:40

inadmissible de balancer une source sans exemple, sans donnee, sans commentaire.
Heureusement ya d'autres sources plus faciles a utiliser.
Dommage pour toi mais je crois que ta source restera au fond d'un dossier, perdue a tout jamais.

pratique pour nos commentaires, on a juste a faire des copier-coller de tes sources aux autres

Commentaire de coucou747 le 30/03/2005 15:41:36

willinfeo un peu de respect, ça fait deux sources pour lesquels tu ne rédige pas ton commentaire en mettant juste inadmissible... on dirait que t'as même pas ouvert le zip...

var $VPi=3.141592653589793;

avoue que c'est joli de voir que certains mettent 16 chiffres à une variable alors que php n'en suposte pas tant...
tapes :
<?php
$var=3.141592653589793;
echo $var;
?>

et tu vois à l'écran :

3.14159265359

a part ça, tu pourrais quand même mettre des quotes dans ton code html... WIDTH=30...

et c'est vrai que sans l'exemple, ni le screen... on ne peut pas juger le coté fonctionnel de ta source...

if ($I!=0){ $this->DrawInt($Matr[$I-1][1],$Matr[$I-1][0],$I-1); }

devrait être remplacé par :

if ($I)$this->DrawInt($Matr[$I-1][1],$Matr[$I-1][0],$I-1);


et enfin, voici les deux seules lignes commentées :
$St0=0; // 3Pi/4 (var) à 2Pi
$St2=0; // 3Pi/4 à Pi/4 (var)

on ne comprends pas vraiment ce que veulent dire tes commentaires... et tu devrait vraiment commenter plus...

Commentaire de GRenard le 30/03/2005 19:47:21

Je n'avais pas vu
var $VPi=3.141592653589793;
var $VPi2=6.283185307179586;
var $VPi12=1.570796326794897;
var $VPi32=4.71238898038469;

Au lieu de faire ca... tu devrais utiliser les constantes de PHP... elles te fournient gentillement PI :)
C'est M_PI
tu verras, tu vas aussi avoir PI2...

Regarde ceci :
http://ca.php.net/manual/fr/reserved.constants.standard.php

Commentaire de lefter le 30/03/2005 21:52:56

J'ai rajouté une source commenté!!!


                                        :-)

Commentaire de ImmortalPC le 26/05/2005 12:48:30

Salut,
ton code html n'est pas bon du tout en + !!!!!
Tiens je l'ai modif :
<?php

class GraphicQuart {
var $QuartValue;
var $Titre;
var $Titre0;
var $Angle;
var $Color;
var $QuartNum;
var $Prop;
var $SumValue;
var $MapQuart;
var $CenterPt;
var $TxtQuart;
var $Img;
var $Arc;
var $Arc2;
var $ArcEch;
var $XBaseRef;
var $YBaseRef;
var $YBaseRef2;
var $ArcNum;
var $White;
var $Blue;
var $VPi=3.141592653589793;
var $VPi2=6.283185307179586;
var $VPi12=1.570796326794897;
var $VPi32=4.71238898038469;
var $Report;

function SetColor($IndexColor,$Couleur){
$Rouge=hexdec(substr($Couleur,1,2));
$Vert=hexdec(substr($Couleur,3,2));
$Bleu=hexdec(substr($Couleur,5,2));
$this->Color[$IndexColor][0]=ImageColorAllocate($this->Img,$Rouge,$Vert,$Bleu);
$this->Color[$IndexColor][1]=ImageColorAllocate($this->Img,$Rouge*0.9,$Vert*0.9,$Bleu*0.9);
$this->Color[$IndexColor][2]=ImageColorAllocate($this->Img,$Rouge*0.8,$Vert*0.8,$Bleu*0.8);
$this->Color[$IndexColor][3]=$Couleur;
}

function DefaultColor(){
$this->SetColor(0,'#FF0000');
$this->SetColor(1,'#00FF00');
$this->SetColor(2,'#0000FF');
$this->SetColor(3,'#FFFF00');
$this->SetColor(4,'#FF00FF');
$this->SetColor(5,'#00FFFF');
$this->SetColor(6,'#7F7F7F');
$this->SetColor(7,'#7F0000');
$this->SetColor(8,'#007F00');
$this->SetColor(9,'#00007F');
$this->SetColor(10,'#7F7F00');
$this->SetColor(11,'#7F007F');
$this->SetColor(12,'#007F7F');
$this->SetColor(13,'#C0C0C0');
$this->SetColor(14,'#C00000');
$this->SetColor(15,'#00C000');
$this->SetColor(16,'#0000C0');
$this->SetColor(17,'#C0C000');
$this->SetColor(18,'#C000C0');
$this->SetColor(19,'#00C0C0');
$this->SetColor(20,'3F3F3F');
$this->SetColor(21,'#3F0000');
$this->SetColor(22,'#003F00');
$this->SetColor(23,'#00003F');
$this->SetColor(24,'#3F3F00');
$this->SetColor(25,'#3F003F');
$this->SetColor(26,'#003F3F');
}

function CreerQuart($Titre,$XRayon,$YRayon,$XEclateRayon,$YEclateRayon,$Epaisseur){
$this->Titre0=$Titre;
$this->QuartNum=0;
$this->SumValue=0;
$this->Prop[0]=$XRayon;
$this->Prop[1]=$YRayon;
$this->Prop[2]=$XEclateRayon;
$this->Prop[3]=$YEclateRayon;
$this->Prop[4]=$Epaisseur;
$Largueur=2*($this->Prop[0]+$this->Prop[2]);
$Hauteur=2*($this->Prop[1]+$this->Prop[3])+$this->Prop[4];
$this->Report.= "Limg=$Largueur  Himg=$Hauteur<br />\r\n";
$this->CenterPt[0]=$Largueur/2;
$this->CenterPt[1]=($Hauteur-$this->Prop[4])/2;
$this->Img=ImageCreateTrueColor($Largueur,$Hauteur);
$this->White=ImageColorAllocate($this->Img,255,255,255);
$this->Blue=ImageColorAllocate($this->Img,0,0,255);
$this->DefaultColor();
}

function AjouterQuart($Value,$Titre){
$this->Titre[$this->QuartNum]=$Titre;
$this->QuartValue[$this->QuartNum++]=$Value;
$this->SumValue+=$Value;
}

function DrawQuart($Matr){
for ($I=0;$I<$this->QuartNum;$I++){
$Deb=$Matr[$I][0];
$Fin=$Matr[$I][1];
if ($Deb!=$Fin){
$Moy=($Deb+$Fin)/2;
$RefX=$this->CenterPt[0]+$this->Prop[2]*cos($Moy);
$RefY=$this->CenterPt[1]+$this->Prop[3]*sin($Moy);
$Step=($Fin-$Deb)/200;
$X1=$RefX; $Y1=$RefY;
for ($j=$Deb;$j<=$Fin;$j+=$Step){
$X2=$RefX+cos($j)*$this->Prop[0];
$Y2=$RefY+sin($j)*$this->Prop[1];
imageline($this->Img,$X1,$Y1,$X2,$Y2,$this->Color[$I][0]);
$X1=$X2;$Y1=$Y2;
}
$X2=$RefX+cos($Fin)*$this->Prop[0];
$Y2=$RefY+sin($Fin)*$this->Prop[1];
imageline($this->Img,$X1,$Y1,$X2,$Y2,$this->Color[$I][0]);
imageline($this->Img,$X2,$Y2,$RefX,$RefY,$this->Color[$I][0]);
$X1=$RefX+cos($Moy)*0.8*$this->Prop[0];
$Y1=$RefY+sin($Moy)*0.8*$this->Prop[1];
imagefilltoborder($this->Img,$X1,$Y1,$this->Color[$I][0],$this->Color[$I][0]);
}
}
}

function BorderIntQuart($Matr){
$St0=0; // 3Pi/4 (var) à 2Pi
$St2=0; // 3Pi/4 à Pi/4 (var)
for ($I=0;$I<$this->QuartNum;$I++){
if (($Matr[$I][0]>$this->VPi32)&&($St2==0)){ $St2=$I; }
if ($Matr[$I][0]<$this->VPi12){ $St0=$I; }
}
for ($I=$St2;$I<$this->QuartNum;$I++){
if ($I!=0){ $this->DrawInt($Matr[$I-1][1],$Matr[$I-1][0],$I-1); }
$this->DrawInt($Matr[$I][0],$Matr[$I][1],$I);
}
$this->DrawInt($Matr[$this->QuartNum-1][1],$Matr[$this->QuartNum-1][0],$this->QuartNum-1);
$this->DrawInt($Matr[0][0],$Matr[0][1],0);
for ($I=0;$I<=$St0;$I++){
$this->DrawInt($Matr[$I][1],$Matr[$I][0],$I);
$this->DrawInt($Matr[$I+1][0],$Matr[$I+1][1],$I+1);
}
for ($I=($St2-1);$I>=$St0;$I--){
$this->DrawInt($Matr[$I][0],$Matr[$I][1],$I);
if ($I!=0){ $this->DrawInt($Matr[$I-1][1],$Matr[$I-1][0],$I-1); }
}
}

function DrawInt($Vect,$Vect2,$Num){
if ($Vect!=$Vect2){
$Moy=($Vect+$Vect2)/2;
$RefX=$this->CenterPt[0]+$this->Prop[2]*cos($Moy);
$RefY=$this->CenterPt[1]+$this->Prop[3]*sin($Moy);
$RefY2=$RefY+$this->Prop[4];
$X1=$RefX+cos($Vect)*$this->Prop[0];
$Y1=$RefY+sin($Vect)*$this->Prop[1];
$Poly[0]=$RefX; $Poly[1]=$RefY;
$Poly[2]=$RefX; $Poly[3]=$RefY2;
$Poly[4]=$X1; $Poly[5]=$Y1+$this->Prop[4];
$Poly[6]=$X1; $Poly[7]=$Y1;
imagefilledpolygon($this->Img,$Poly,4,$this->Color[$Num][2]);
}
}

function BorderExtQuart($Matr){
for ($I=0;$I<$this->QuartNum;$I++){
$Deb=$Matr[$I][0];
$Fin=$Matr[$I][1];
$Moy=($Deb+$Fin)/2; $Step=($Fin-$Deb)/200;
if ($Deb!=$Fin){
$RefX=$this->CenterPt[0]+$this->Prop[2]*cos($Moy);
$RefY=$this->CenterPt[1]+$this->Prop[3]*sin($Moy);
if ($Deb>$this->VPi){ return; }
$P=0; $FinP=$Fin;
if ($FinP>$this->VPi){ $FinP=$this->VPi; }
$j=$Deb;
while (($j<=$FinP)&&($j<$this->VPi)){
$Y=$RefY+sin($j)*$this->Prop[1];
$BorderP[$P++]=$RefX+cos($j)*$this->Prop[0];
$BorderP[$P++]=$Y;
$j+=$Step;
}
if ($Y<=$RefY){
$X0=$RefX+cos($FinP)*$this->Prop[0];
$Y0=$RefY+sin($FinP)*$this->Prop[1];
$BorderP[$P++]=$X0;
$BorderP[$P++]=$Y0;
$BorderP[$P++]=$X0;
$BorderP[$P++]=$Y0+$this->Prop[4];
}
for ($j=($P-2);$j>=0;$j--){
if (($j%2)==0){$BorderP[$P++]=$BorderP[$j]; } else { $BorderP[$P++]=$BorderP[$j]+$this->Prop[4];}
}
imagefilledpolygon($this->Img,$BorderP,$P/2,$this->Color[$I][1]);
}
}
}

function Draw($FileName){
imagefill($this->Img,0,0,$this->White);
if ($this->SumValue==0){ return; }

$Somme=0;$Deb=0;
for ($I=0;$I<$this->QuartNum;$I++){
$MatrixMake[$I][0]=2*$this->VPi*$Somme/$this->SumValue;$Somme+=$this->QuartValue[$I];
$MatrixMake[$I][1]=2*$this->VPi*$Somme/$this->SumValue;$MatrixMake[$I][2]=$I;
}
$this->BorderIntQuart($MatrixMake);
$this->DrawQuart($MatrixMake);
$this->BorderExtQuart($MatrixMake);

ImagePng($this->Img,($FileName));
echo '<table align="center"><tr><td colspan="3" style="text-align:center;"><h3>',$this->Titre0,'</h3><br /></td></tr>',"\r\n"
,'<tr><td rowspan="',($this->QuartNum+2),'"><img src="',$FileName,'" alt="" /></td></tr>',"\r\n";
for($I=0;$I<$this->QuartNum;$I++){
            echo '<tr><td style="width:30px;">&nbsp;</td><td style="width:150px; background-color:',$this->Color[$I][3],'; text-align:center; font-weight: bold;">',$this->Titre[$I],'</td></tr>',"\r\n";
        }
echo '</table>',"\r\n";

}
}

?>
@++

Commentaire de lefter le 08/07/2005 15:16:32

Tu parle des TR et des TD, ils sont fermés inplicitement par IE et Firefox!
Donc, pour moi, pas d'erreur en HTML !

Merci quand même!

Commentaire de coucou747 le 08/07/2005 15:31:58

ce n'est pas reqspecter les normes que de dire qu'il n'y a pas d'erreur parce-que ça fonctionne...

Commentaire de lefter le 26/07/2005 10:22:12

Mise à jour le 26 juillet 2005,
Correction de la syntaxe du code HTML, et correction des bugs d'affichages des quartiers!
:-)

Commentaire de ImmortalPC le 26/07/2005 20:24:19

Salut,
je vois pas la différance :-/
1) Utilise les ' au lieu des "
2) Adieux html bonjour XHTML
Regarde ce que j'ai fait plus haut !!!
@+

Commentaire de patrickchevin le 15/02/2007 10:15:02

Bonjour,

Le code à l'air assez lourd (beaucoup de variables assignées alors que pas tjrs utilisées). A part ça, si ça marche...
Est-ce que je peux utiliser la source sur mon site pour faire des stats
visiteurs ?

Merci,
Patrick.

http://pcnice.free.fr

Commentaire de lefter le 19/02/2007 00:10:48

Toutes les sources que je mets à disposition sont libres de droits alors tu peux les utiliser sans problème...

Cela me fait plutôt plaisir qu'elle soit utilisé. (désolé pour les mots oubliés)

Commentaire de AliBabNet le 30/04/2007 17:22:55

Marche très bien.
Un seul détail: il faut penser à créer le répertoire img/camembert, sinon ça marche pas.

Bravo et merci

Philippe

Commentaire de espada le 22/06/2007 12:00:09

y a pas un code qui marche sans modif ici? j suis debutant et je travail sur un projet qui necessite des stats, que me conceillez vous?

Commentaire de espada le 22/06/2007 12:00:35

y a pas un code qui marche sans modif ici? j suis debutant et je travail sur un projet qui necessite des stats, que me conceillez vous?

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mars 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
293031    

Consulter la suite du CalendriCode

 
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 : 0,406 sec (4)

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