Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1786 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  [PHP][JS] Vraiment Bizzard

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[PHP][JS] Vraiment Bizzard

n°562360
bozocarzu
Posté le 08-11-2003 à 16:35:49  profilanswer
 

J'ai realise un script en javascript qui permet de faire un degradé de couleur.
 
J'ai voulu convertir le script JS en code php (se que j'ai reussi :)) mais a ma grande surprise les dégradé ne sont pas de la meme qualité !!
 
Alors que le code est exactement le meme (mais pas le meme language)!
 
Regardez de vous meme : http://81.51.252.109/action.php
(le prmier degradé est rapide a s'afficher, mais celui en JS met environ 15s, il y'a 6 000 couleurs a calculer)
 
Je ne comprend pas pourquoi cette difference

mood
Publicité
Posté le 08-11-2003 à 16:35:49  profilanswer
 

n°562366
gizmo
Posté le 08-11-2003 à 16:41:46  profilanswer
 

/o\ 710Ko pour deux bouts d'image ridicule!
 
T'est sûr que tu veux le faire en php?

n°562369
bozocarzu
Posté le 08-11-2003 à 16:46:14  profilanswer
 

Ce n'est pas juste des image ridicule comme tu dis, sa rentre dans un projet.
Je ne suis pas obliger de le faire en php mais l' JS est trop long d'exuction.


Message édité par bozocarzu le 08-11-2003 à 16:46:35
n°562374
gizmo
Posté le 08-11-2003 à 16:48:44  profilanswer
 

euh... t'as tester ailleurs qu'en local? Parce que charger 700Ko c'est nettement plus lourd et long que d'attendre 6 pauvres secondes.

n°562381
bozocarzu
Posté le 08-11-2003 à 16:57:23  profilanswer
 

Non j'ai pas tester hors lan, elle mets combien de temps a charger la page pour toi ?
 
Parceque sa ne devrait pas vrarier temps que sa

n°562385
bozocarzu
Posté le 08-11-2003 à 17:00:54  profilanswer
 

Mais mon probleme n'est pas le temps de chargement, car de toute façon c'est un projet intranet.
 
Mon probleme, c'est qu'en php le degradée est plus moche qu'en JS et je ne sais pas d'ou sa peut venir

n°562388
sashock
Posté le 08-11-2003 à 17:02:55  profilanswer
 

si tu mettais le code des 2 ca pourrait aider déja ;)

n°562390
bozocarzu
Posté le 08-11-2003 à 17:07:02  profilanswer
 

Les codes se sont les meme mais les voila :
 
EN JavaScript

Code :
  1. hexadecimal="0123456789ABCDEF";
  2. color0=new Array(255,0,255,0,255,0);
  3. color1=new Array(255,255,0,255,0,0);
  4. color2=new Array(255,0,255,255,0,0);
  5. color3=new Array(0,0,255,255,0,255);
  6. color4=new Array(0,0,255,0,255,255);
  7. color5=new Array(0,255,0,0,255,255);
  8. function codehexa(R,G,B){
  9. R=hexadecimal.charAt(Math.floor(R/16))+hexadecimal.charAt(R%16);
  10. G=hexadecimal.charAt(Math.floor(G/16))+hexadecimal.charAt(G%16);
  11. B=hexadecimal.charAt(Math.floor(B/16))+hexadecimal.charAt(B%16);
  12. return "#"+R+G+B;
  13. }
  14. function ligne(color){
  15. i=40;
  16. while (i<81){
  17.   r=Math.floor(color[0]+(i-40)*(color[1]-color[0])/40);
  18.   g=Math.floor(color[2]+(i-40)*(color[3]-color[2])/40);
  19.   b=Math.floor(color[4]+(i-40)*(color[5]-color[4])/40);
  20.   document.write('<td bgColor=\"'+codehexa(r,g,b)+'\" onClick=\"couleur(1,bgColor);\" title=\"Choisis la couleur ['+codehexa(r,g,b)+']\" width=\"2\" height=\"2\"></td>');
  21.   i++;
  22. }
  23. }
  24. function degrade(cr){
  25. cm=new Array(255,255,255,255,255,255);
  26. cm2=cr;
  27. j=0;
  28. while(j<15){
  29.   document.write('<tr>');
  30.   ra=0;
  31.   while(ra<6){
  32.    if(cr[ra]!=cm[ra]){
  33.     cm[ra]=cm[ra]-17;
  34.    }
  35.    ra++;
  36.   }
  37.   ligne(cm);
  38.   document.write('</tr>');
  39.   j++;
  40. }
  41. j=0;
  42. while(j<15){
  43.   document.write('<tr>');
  44.   ra=0;
  45.   while(ra<6){
  46.    if(cr[ra]!=0){
  47.     cm2[ra]=cm2[ra]-17;
  48.    }
  49.    ra++;
  50.   }
  51.   ligne(cm2);
  52.   document.write('</tr>');
  53.   j++;
  54. }
  55. }


 
EN PHP

Code :
  1. $hexadecimal="0123456789ABCDEF";
  2. $color0=Array(255,0,255,0,255,0);
  3. $color1=Array(255,255,0,255,0,0);
  4. $color2=Array(255,0,255,255,0,0);
  5. $color3=Array(0,0,255,255,0,255);
  6. $color4=Array(0,0,255,0,255,255);
  7. $color5=Array(0,255,0,0,255,255);
  8. function codehexa($R,$G,$B){
  9. global $hexadecimal;
  10. $R=$hexadecimal{floor($R/16)}.$hexadecimal{floor($R/16)};
  11. $G=$hexadecimal{floor($G/16)}.$hexadecimal{floor($G/16)};
  12. $B=$hexadecimal{floor($B/16)}.$hexadecimal{floor($B/16)};
  13. return "#$R$G$B";
  14. }
  15. function ligne($color){
  16. $i=40;
  17. while ($i<81){
  18.   $r=floor($color[0]+($i-40)*($color[1]-$color[0])/40);
  19.   $g=floor($color[2]+($i-40)*($color[3]-$color[2])/40);
  20.   $b=floor($color[4]+($i-40)*($color[5]-$color[4])/40);
  21.   echo "<td bgColor='".codehexa($r,$g,$b)."' onClick=\"couleur(1,bgColor);\" title=\"Choisis la couleur [".codehexa($r,$g,$b)."]\" width=\"2\" height=\"2\"></td>";
  22.   $i++;
  23. }
  24. }
  25. function degrade($cl){
  26. global $color1, $color2, $color3, $color4, $color5;
  27. $cr=$$cl;
  28. $cm=Array(255,255,255,255,255,255);
  29. $cm2=$cr;
  30. $j=0;
  31. while($j<15){
  32.   echo "<tr>";
  33.   $ra=0;
  34.   while($ra<6){
  35.    if($cr[$ra]!=$cm[$ra]){
  36.     $cm[$ra]=$cm[$ra]-17;
  37.    }
  38.    $ra++;
  39.   }
  40.   ligne($cm);
  41.   echo "</tr>";
  42.   $j++;
  43. }
  44. $j=0;
  45. while($j<15){
  46.   echo "<tr>";
  47.   $ra=0;
  48.   while($ra<6){
  49.    if($cr[$ra]!=0){
  50.     $cm2[$ra]=$cm2[$ra]-17;
  51.    }
  52.    $ra++;
  53.   }
  54.   ligne($cm2);
  55.   echo "</tr>";
  56.   $j++;
  57. }
  58. }


 
Et voici le code qui permet d'exucuter les fonctions :

Code :
  1. <table boder=0 cellspacing="0" cellpadding="0">
  2. <tr>
  3.   <td><table boder=0 cellspacing="0" cellpadding="0"><? degrade("color1" ) ?></table></td>
  4.   <td><table boder=0 cellspacing="0" cellpadding="0"><? degrade("color2" ) ?></table></td>       <td><table boder=0 cellspacing="0" cellpadding="0"><? degrade("color3" ) ?></table></td>
  5.   <td><table boder=0 cellspacing="0" cellpadding="0"><? degrade("color4" ) ?></table></td>
  6.   <td><table boder=0 cellspacing="0" cellpadding="0"><? degrade("color5" ) ?></table></td>
  7.   <td><= En PHP</td>
  8. </tr>
  9. </table>
  10. <SCRIPT language=JavaScript src="degrade.js"></script>
  11. <table boder=0 cellspacing="0" cellpadding="0">
  12. <tr>
  13.   <td><table boder=0 cellspacing="0" cellpadding="0"><SCRIPT language=JavaScript>degrade(color1)</SCRIPT></table></td>
  14.   <td><table boder=0 cellspacing="0" cellpadding="0"><SCRIPT language=JavaScript>degrade(color2)</SCRIPT></table></td>         
  15.   <td><table boder=0 cellspacing="0" cellpadding="0"><SCRIPT language=JavaScript>degrade(color3)</SCRIPT></table></td>
  16.   <td><table boder=0 cellspacing="0" cellpadding="0"><SCRIPT language=JavaScript>degrade(color4)</SCRIPT></table></td>
  17.   <td><table boder=0 cellspacing="0" cellpadding="0"><SCRIPT language=JavaScript>degrade(color5)</SCRIPT></table></td>
  18.   <td><= En JavaScript</td>
  19. </tr>
  20. </table>

n°562391
gizmo
Posté le 08-11-2003 à 17:07:50  profilanswer
 

BozoCarzu a écrit :

Non j'ai pas tester hors lan, elle mets combien de temps a charger la page pour toi ?
 
Parceque sa ne devrait pas vrarier temps que sa  


 
48 sec donc 44 rien que pour la partie php...

n°562393
bozocarzu
Posté le 08-11-2003 à 17:11:34  profilanswer
 

Moi en lan, la partie PHP se met en 1s et la partiz JS en 10 secondes.
 
Tu as une idée pour la diffrence de qualité ?


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  [PHP][JS] Vraiment Bizzard

 

Sujets relatifs
[PHP] Afficher la valeur des boutons radio[PHP] augmenter le max_execution_time dans le php.ini
[PHP] détruire toutes les var d'une session sauf certaines...comment eviter ceci .... ? (pages PHP)
[PHP] Calculer le pourcentage de majuscules dans une chaineHelp !!! Excel et PHP/MySQL
[PHP] Questions sur auto_increment[PHP] petit prob après passage d'easyPhp à BigApache...
[PHP] Pb requete sql ??[PHP/MYSQL] Quel hebergeur gratuit support l'envoie d'email?
Plus de sujets relatifs à : [PHP][JS] Vraiment Bizzard


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR