Rewrite color inversal in a reusable way

This commit is contained in:
Oliver Brakmann
2016-08-26 22:06:10 +02:00
parent d0109491a7
commit 8ad18ad161
3 changed files with 20 additions and 8 deletions

View File

@@ -250,6 +250,12 @@ namespace OpenRA.Widgets
return trimmed;
}
public static Color GetContrastColor(Color fgColor, Color bgDark, Color bgLight)
{
var fg = new HSLColor(fgColor);
return fg.RGB == Color.White || fg.L > 80 ? bgDark : bgLight;
}
}
public class CachedTransform<T, U>