Changeset - 0b17df70395d
[Not reviewed]
Merge default
0 1 0
Jason Maltzen (jmaltzen) - 7 years ago 2018-05-18 01:25:48
jason.maltzen@unsanctioned.net
Merge
1 file changed with 56 insertions and 7 deletions:
0 comments (0 inline, 0 general)
PlayerProfile.cs
Show inline comments
...
 
@@ -511,2 +511,52 @@ namespace DesertPaintLab
 
        
 
        static public PaintColor RgbToHsv(PaintColor color)
 
        {
 
            float h = 0;
 
            float s = 0;
 
            float r = color.Red / 255.0f;
 
            float g = color.Green / 255.0f;
 
            float b = color.Blue / 255.0f;
 
            float cmax = Math.Max(Math.Max(r, g), b);
 
            float cmin = Math.Min(Math.Min(r, g), b);
 
            float cd = cmax - cmin;
 
            if (cd == 0)
 
            {
 
                h = 0;
 
            }
 
            else if (cmax == r)
 
            {
 
                h = (((g - b) / cd) % 6) / 6f;
 
            }
 
            else if (cmax == g)
 
            {
 
                h = (((b - r) / cd) + 2) / 6f;
 
            }
 
            else
 
            {
 
                h = (((r - g) / cd) + 4) / 6f;
 
            }
 

	
 
            if (cmax == 0)
 
            {
 
                s = 0;
 
            }
 
            else
 
            {
 
                s = cd / cmax;
 
            }
 

	
 
            if (h < 0)
 
            {
 
                h = 1 + h;
 
            }
 

	
 
            if (h >= 1)
 
            {
 
                h = 0;
 
            }
 

	
 

	
 
            return new PaintColor((byte)(h * 255), (byte)(s * 255), (byte)(cmax * 255));
 
        }
 

	
 
        public void ExportWikiFormat(TextWriter writer, SortedDictionary<string, PaintRecipe> recipeDict)
...
 
@@ -524,9 +574,4 @@ namespace DesertPaintLab
 
                    colorLine += "style=\"font-weight: bold; background-color: #" + color.Red.ToString("X2") + color.Green.ToString("X2") + color.Blue.ToString("X2") + ";";
 
                    float rPortion = color.Red / 255.0f;
 
                    float gPortion = color.Green / 255.0f;
 
                    float bPortion = color.Blue / 255.0f;
 
                    float maxColor = Math.Max(rPortion, Math.Max(gPortion, bPortion));
 
                    float minColor = Math.Min(rPortion, Math.Min(gPortion, bPortion));
 
                    float luminance = (maxColor - minColor) * 0.5f;
 
                    if (luminance < 0.5f)
 
                    PaintColor hsvColor = RgbToHsv(color);
 
                    if (hsvColor.Blue < 200) // value
 
                    {
...
 
@@ -535,2 +580,6 @@ namespace DesertPaintLab
 
                    }
 
                    else
 
                    {
 
                        colorLine += "color: #000000;";
 
                    }
 
                    colorLine += "\" | " + color.Name + " || ";
0 comments (0 inline, 0 general)