2f107db...5202af9
This commit is contained in:
@@ -12,22 +12,24 @@ namespace Barotrauma
|
||||
{
|
||||
if (dictionary == null)
|
||||
{
|
||||
dictionary = new Dictionary<Color, ConsoleColor>();
|
||||
dictionary.Add(Color.White, ConsoleColor.White);
|
||||
dictionary.Add(Color.Gray, ConsoleColor.Gray);
|
||||
dictionary.Add(Color.LightGray, ConsoleColor.Gray);
|
||||
dictionary.Add(Color.DarkGray, ConsoleColor.Gray);
|
||||
dictionary.Add(Color.Red, ConsoleColor.Red);
|
||||
dictionary.Add(Color.DarkRed, ConsoleColor.DarkRed);
|
||||
dictionary.Add(Color.Yellow, ConsoleColor.Yellow);
|
||||
dictionary.Add(Color.Orange, ConsoleColor.Yellow);
|
||||
dictionary.Add(Color.Green, ConsoleColor.Green);
|
||||
dictionary.Add(Color.Lime, ConsoleColor.Green);
|
||||
dictionary.Add(Color.Blue, ConsoleColor.Blue);
|
||||
dictionary.Add(Color.Cyan, ConsoleColor.Cyan);
|
||||
dictionary.Add(Color.DarkBlue, ConsoleColor.DarkBlue);
|
||||
dictionary.Add(Color.Pink, ConsoleColor.Magenta);
|
||||
dictionary.Add(Color.Magenta, ConsoleColor.Magenta);
|
||||
dictionary = new Dictionary<Color, ConsoleColor>
|
||||
{
|
||||
{ Color.White, ConsoleColor.White },
|
||||
{ Color.Gray, ConsoleColor.Gray },
|
||||
{ Color.LightGray, ConsoleColor.Gray },
|
||||
{ Color.DarkGray, ConsoleColor.Gray },
|
||||
{ Color.Red, ConsoleColor.Red },
|
||||
{ Color.DarkRed, ConsoleColor.DarkRed },
|
||||
{ Color.Yellow, ConsoleColor.Yellow },
|
||||
{ Color.Orange, ConsoleColor.Yellow },
|
||||
{ Color.Green, ConsoleColor.Green },
|
||||
{ Color.Lime, ConsoleColor.Green },
|
||||
{ Color.Blue, ConsoleColor.Blue },
|
||||
{ Color.Cyan, ConsoleColor.Cyan },
|
||||
{ Color.DarkBlue, ConsoleColor.DarkBlue },
|
||||
{ Color.Pink, ConsoleColor.Magenta },
|
||||
{ Color.Magenta, ConsoleColor.Magenta }
|
||||
};
|
||||
}
|
||||
|
||||
ConsoleColor val = ConsoleColor.White;
|
||||
@@ -35,8 +37,48 @@ namespace Barotrauma
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
return GetClosestConsoleColor(xnaCol);
|
||||
}
|
||||
|
||||
return ConsoleColor.White;
|
||||
public static ConsoleColor GetClosestConsoleColor(Color color)
|
||||
{
|
||||
Vector3 hls = ToolBox.RgbToHLS(color.ToVector3());
|
||||
if (hls.Z < 0.5)
|
||||
{
|
||||
// we have a grayish color
|
||||
switch ((int)(hls.Y * 3.5))
|
||||
{
|
||||
case 0: return ConsoleColor.Black;
|
||||
case 1: return ConsoleColor.DarkGray;
|
||||
case 2: return ConsoleColor.Gray;
|
||||
default: return ConsoleColor.White;
|
||||
}
|
||||
}
|
||||
int hue = (int)Math.Round(hls.X / 60, MidpointRounding.AwayFromZero);
|
||||
if (hls.Y < 0.4)
|
||||
{
|
||||
// dark color
|
||||
switch (hue)
|
||||
{
|
||||
case 1: return ConsoleColor.DarkYellow;
|
||||
case 2: return ConsoleColor.DarkGreen;
|
||||
case 3: return ConsoleColor.DarkCyan;
|
||||
case 4: return ConsoleColor.DarkBlue;
|
||||
case 5: return ConsoleColor.DarkMagenta;
|
||||
default: return ConsoleColor.DarkRed;
|
||||
}
|
||||
}
|
||||
// bright color
|
||||
switch (hue)
|
||||
{
|
||||
case 1: return ConsoleColor.Yellow;
|
||||
case 2: return ConsoleColor.Green;
|
||||
case 3: return ConsoleColor.Cyan;
|
||||
case 4: return ConsoleColor.Blue;
|
||||
case 5: return ConsoleColor.Magenta;
|
||||
default: return ConsoleColor.Red;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user