Mazda3 | Bon j'ai trouver une fonction semblable que j'ai adapté en Java, pour ceux que ça interesse ...
Code :
- public String degrade(int nombreNiveau, int niveauActuel, String couleur1, String couleur2){
- int R1 = Integer.parseInt(couleur1.substring(0,2),16);
- int G1 = Integer.parseInt(couleur1.substring(2,4),16);
- int B1 = Integer.parseInt(couleur1.substring(4,6),16);
- int pR=(Integer.parseInt(couleur2.substring(0,2),16)-R1)/nombreNiveau;
- int pG=(Integer.parseInt(couleur2.substring(2,4),16)-G1)/nombreNiveau;
- int pB=(Integer.parseInt(couleur2.substring(4,6),16)-B1)/nombreNiveau;
- String valHex="0123456789ABCDEF";
- String R=""+valHex.charAt((R1+pR*niveauActuel)/16)+valHex.charAt((R1+pR*niveauActuel)%16);
- String G=""+valHex.charAt((G1+pG*niveauActuel)/16)+valHex.charAt((G1+pG*niveauActuel)%16);
- String B=""+valHex.charAt((B1+pB*niveauActuel)/16)+valHex.charAt((B1+pB*niveauActuel)%16);
- return "#"+R+G+B;
- }
|
Message édité par Mazda3 le 30-12-2004 à 15:53:05
|