# HG changeset patch # User Jason Maltzen # Date 2016-01-15 17:23:21 # Node ID 1846a628223cd26acb8898679169e401c10a91d4 # Parent e69054de58afcad232f5c278cbc6dfc66f256fef Use luminance value to determine whether exported wiki color text should be white-on-color instead of default black-on-color diff --git a/PlayerProfile.cs b/PlayerProfile.cs --- a/PlayerProfile.cs +++ b/PlayerProfile.cs @@ -438,6 +438,7 @@ namespace DesertPaintLab public void ExportWikiFormat(TextWriter writer) { PaintRecipe recipe; + List> missing = new List>(); using (writer) { writer.WriteLine("{| class='wikitable sortable' border=\"1\" style=\"background-color:#DEB887;\""); @@ -447,7 +448,13 @@ namespace DesertPaintLab writer.WriteLine("|-"); string colorLine = "| "; colorLine += "style=\"font-weight: bold; background-color: #" + color.Red.ToString("X2") + color.Green.ToString("X2") + color.Blue.ToString("X2") + ";"; - if (color.Red < 128 && color.Green < 128 && color.Blue < 128) + 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) { // dark color gets light text colorLine += " color: #FFFFFF;"; @@ -465,6 +472,11 @@ namespace DesertPaintLab // no recipe } colorLine += " || "; + + if (recipe.CheckMissingReactions(ref missing) == false) + { + colorLine += "Y"; + } writer.WriteLine(colorLine); } writer.WriteLine("|}");