Color MakeBackdropColor(Color BaseColor) { var f = new FloatingColor(BaseColor).MakeHSL(); f.B = Math.Min(.2f, Math.Max(0, f.B - .2f)); f.G = Math.Min(.2f, Math.Max(0, f.G - .2f)); return(f.MakeRGB().ConvertToColor()); }
public FloatingColor Evaluate(float Value) { FloatingColor R = new FloatingColor() { R = X.Evaluate(Value), G = Y.Evaluate(Value), B = Z.Evaluate(Value), A = W.Evaluate(Value) }; return((_HSL) ? R.MakeRGB() : R); }
public UnitConfigurationView( UnitConfiguration UnitConfiguration, Faction Faction, UnitConfigurationRenderer Renderer, float Scale) { this.Scale = Scale; Color[] colors = UnitConfiguration.UnitClass == UnitClass.BLOCK || UnitConfiguration.UnitClass == UnitClass.MINEFIELD ? new Color[] { Color.White } : Faction.Colors; if (!UnitConfiguration.IsVehicle) { colors = colors.ToArray(); for (int i = 0; i < colors.Length; ++i) { var f = new FloatingColor(colors[i]); f = f.MakeHSL(); f.B = Math.Min(1, f.B + .1f); colors[i] = f.MakeRGB().ConvertToColor(); } } _Vertices = new Vertex[colors.Length * 4]; float barHeight = 1f / colors.Length; var backgroundRenderInfo = Renderer.GetRenderInfo(null); _BackgroundTexture = backgroundRenderInfo.Item1; var v = backgroundRenderInfo.Item2; for (int i = 0; i < colors.Length; ++i) { float yT = v[0].Y + ((float)i / colors.Length) * (v[0].Y + v[2].Y); float yB = v[0].Y + ((float)(i + 1) / colors.Length) * (v[0].Y + v[2].Y); _Vertices[i * 4] = new Vertex(new Vector2f(-.5f, i * barHeight - .5f), colors[i], new Vector2f(v[0].X, yT)); _Vertices[i * 4 + 1] = new Vertex(new Vector2f(.5f, i * barHeight - .5f), colors[i], new Vector2f(v[2].X, yT)); _Vertices[i * 4 + 2] = new Vertex(new Vector2f(.5f, (i + 1) * barHeight - .5f), colors[i], new Vector2f(v[2].X, yB)); _Vertices[i * 4 + 3] = new Vertex(new Vector2f(-.5f, (i + 1) * barHeight - .5f), colors[i], new Vector2f(v[0].X, yB)); } var renderInfo = Renderer.GetRenderInfo(UnitConfiguration); _Texture = renderInfo.Item1; _ImageVertices = new Vertex[4]; Color c = Renderer.RenderDetails[UnitConfiguration.UniqueKey].OverrideColor; if (c.R == 0 && c.G == 0 && c.B == 0) { c = colors.ArgMax(i => new FloatingColor(i).Luminosity()); } var tl = new Vector2f(-.5f, -.5f); var tr = new Vector2f(.5f, -.5f); var br = new Vector2f(.5f, .5f); var bl = new Vector2f(-.5f, .5f); _ImageVertices[0] = new Vertex(tl, c, renderInfo.Item2[0]); _ImageVertices[1] = new Vertex(tr, c, renderInfo.Item2[1]); _ImageVertices[2] = new Vertex(br, c, renderInfo.Item2[2]); _ImageVertices[3] = new Vertex(bl, c, renderInfo.Item2[3]); _Bounds = new Rectangle(new Vector2f(-.5f, -.5f) * Scale, new Vector2f(1, 1) * Scale); }