UN CAMEMBERT ET UN EN 3D ET ÉCLATÉ

cs_GRenard Messages postés 1662 Date d'inscription lundi 16 septembre 2002 Statut Membre Dernière intervention 30 juillet 2008 - 30 mars 2005 à 02:45
cs_espada Messages postés 26 Date d'inscription samedi 23 décembre 2006 Statut Membre Dernière intervention 27 février 2008 - 22 juin 2007 à 12:00
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.

https://codes-sources.commentcamarche.net/source/30419-un-camembert-et-un-en-3d-et-eclate

cs_espada Messages postés 26 Date d'inscription samedi 23 décembre 2006 Statut Membre Dernière intervention 27 février 2008
22 juin 2007 à 12:00
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?
cs_espada Messages postés 26 Date d'inscription samedi 23 décembre 2006 Statut Membre Dernière intervention 27 février 2008
22 juin 2007 à 12:00
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?
AliBabNet Messages postés 2 Date d'inscription mardi 13 septembre 2005 Statut Membre Dernière intervention 7 juin 2006
30 avril 2007 à 17:22
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
lefter Messages postés 63 Date d'inscription lundi 7 juin 2004 Statut Membre Dernière intervention 16 mai 2009
19 févr. 2007 à 00:10
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)
patrickchevin Messages postés 1 Date d'inscription jeudi 15 février 2007 Statut Membre Dernière intervention 15 février 2007
15 févr. 2007 à 10:15
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
ImmortalPC Messages postés 954 Date d'inscription mardi 11 mai 2004 Statut Membre Dernière intervention 11 novembre 2008 2
26 juil. 2005 à 20:24
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 !!!
@+
lefter Messages postés 63 Date d'inscription lundi 7 juin 2004 Statut Membre Dernière intervention 16 mai 2009
26 juil. 2005 à 10:22
Mise à jour le 26 juillet 2005,
Correction de la syntaxe du code HTML, et correction des bugs d'affichages des quartiers!
:-)
coucou747 Messages postés 12303 Date d'inscription mardi 10 février 2004 Statut Membre Dernière intervention 30 juillet 2012 44
8 juil. 2005 à 15:31
ce n'est pas reqspecter les normes que de dire qu'il n'y a pas d'erreur parce-que ça fonctionne...
lefter Messages postés 63 Date d'inscription lundi 7 juin 2004 Statut Membre Dernière intervention 16 mai 2009
8 juil. 2005 à 15:16
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!
ImmortalPC Messages postés 954 Date d'inscription mardi 11 mai 2004 Statut Membre Dernière intervention 11 novembre 2008 2
26 mai 2005 à 12:48
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
\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 '',$this->Titre0,'
, ',\"\r\n\"
,'----
QuartNum+2),'">, ',\"\r\n\";
for($I=0;$I<$this->QuartNum;$I++){
echo '----
, Color[$I][3],'; text-align:center; font-weight: bold;">',$this->Titre[$I],', ',\"\r\n\";
}
echo '
',"\r\n";

}
}

?>
@++
lefter Messages postés 63 Date d'inscription lundi 7 juin 2004 Statut Membre Dernière intervention 16 mai 2009
30 mars 2005 à 21:52
J'ai rajouté une source commenté!!!


:-)
cs_GRenard Messages postés 1662 Date d'inscription lundi 16 septembre 2002 Statut Membre Dernière intervention 30 juillet 2008 1
30 mars 2005 à 19:47
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
coucou747 Messages postés 12303 Date d'inscription mardi 10 février 2004 Statut Membre Dernière intervention 30 juillet 2012 44
30 mars 2005 à 15:41
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...
willinfeo Messages postés 55 Date d'inscription vendredi 25 juillet 2003 Statut Membre Dernière intervention 4 décembre 2005
30 mars 2005 à 15:08
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
cs_Kirua Messages postés 3006 Date d'inscription dimanche 14 avril 2002 Statut Membre Dernière intervention 31 décembre 2008
30 mars 2005 à 08:16
viite, un screenshot !
cs_GRenard Messages postés 1662 Date d'inscription lundi 16 septembre 2002 Statut Membre Dernière intervention 30 juillet 2008 1
30 mars 2005 à 02:45
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
Rejoignez-nous