From Second Life Wiki
Les couleurs dans le LSL
LSL possède son propre format de couleur. LSL utilise un Vector pour gérer les couleurs. A la différence du code RGB ou chaque cannaux varie de 0 à 255, les cannaux du LSL varient de 0 à 1.
Format: <x, y, z>
| • float
| x
| –
| rouge
| [0, 1]
|
| • float
| y
| –
| Vert
| [0, 1]
|
| • float
| z
| –
| bleu
| [0, 1]
|
|
Exemples
vector blanc= <1.0, 1.0, 1.0>;
vector gris = <0.5, 0.5, 0.5>;
vector noir = <0.0, 0.0, 0.0>;
vector rouge = <1.0, 0.0, 0.0>;
vector vert = <0.0, 1.0, 0.0>;
vector bleu = <0.0, 0.0, 1.0>;
vector jaune = <1.0, 1.0, 0.0>;
vector cyan = <0.0, 1.0, 1.0>;
vector magenta = <1.0, 0.0, 1.0>;
|
Extraits de code utiles
Quelques fonctions utiles pour stocker ou retrouver des couleurs et leur couche alpha(transparence) à partir d'un integer
integer ColorAlphatoRGBA(vector couleur, float alpha) {
return (((integer)(alpha * 255.0) & 0xFF) << 24) |
(((integer)(couleur.x * 255.0) & 0xFF) << 16) |
(((integer)(couleur.y * 255.0) & 0xFF) << 8) |
((integer)(couleur.z * 255.0) & 0xFF);
}
vector RGBAtoColor(integer rgba) {
return < ((rgba >> 16) & 0xFF) / 255.0, ((rgba >> 8) & 0xFF) / 255.0, (rgba & 0xFF) / 255.0 >;
}
float RGBAtoAlpha(integer rgba) {
return ((rgba >> 24) & 0xFF) / 255.0;
}
|
Articles in category "LSL Color/fr"
There are 11 articles in this category.