Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ hslToRgb() [1/2]

static Microsoft.Xna.Framework.Color Terraria.Main.hslToRgb ( float Hue,
float Saturation,
float Luminosity,
byte a = byte::MaxValue )
inlinestatic

Definition at line 44918 of file Main.cs.

44919 {
44920 byte r;
44921 byte g;
44922 byte b;
44923 if (Saturation == 0f)
44924 {
44925 r = (byte)Math.Round((double)Luminosity * 255.0);
44926 g = (byte)Math.Round((double)Luminosity * 255.0);
44927 b = (byte)Math.Round((double)Luminosity * 255.0);
44928 }
44929 else
44930 {
44931 double num = Hue;
44932 double num2 = ((!((double)Luminosity < 0.5)) ? ((double)(Luminosity + Saturation - Luminosity * Saturation)) : ((double)Luminosity * (1.0 + (double)Saturation)));
44933 double t = 2.0 * (double)Luminosity - num2;
44934 double c = num + 1.0 / 3.0;
44935 double c2 = num;
44936 double c3 = num - 1.0 / 3.0;
44937 c = hue2rgb(c, t, num2);
44938 c2 = hue2rgb(c2, t, num2);
44939 double num3 = hue2rgb(c3, t, num2);
44940 r = (byte)Math.Round(c * 255.0);
44941 g = (byte)Math.Round(c2 * 255.0);
44942 b = (byte)Math.Round(num3 * 255.0);
44943 }
44944 return new Microsoft.Xna.Framework.Color(r, g, b, a);
44945 }
static decimal Round(decimal d)
Definition Math.cs:1096
static double hue2rgb(double c, double t1, double t2)
Definition Main.cs:44947

References Terraria.Main.hue2rgb(), and System.Math.Round().