Added GradientColorBlockWidget

This commit is contained in:
teinarss
2019-04-16 20:24:07 +02:00
committed by Paul Chote
parent b25d0694b8
commit dad29cd3b3
3 changed files with 91 additions and 0 deletions

View File

@@ -238,6 +238,29 @@ namespace OpenRA.Graphics
parent.DrawRGBAVertices(vertices);
}
public void FillRect(float3 a, float3 b, float3 c, float3 d, Color topLeftColor, Color topRightColor, Color bottomRightColor, Color bottomLeftColor)
{
vertices[0] = VertexWithColor(a + Offset, topLeftColor);
vertices[1] = VertexWithColor(b + Offset, topRightColor);
vertices[2] = VertexWithColor(c + Offset, bottomRightColor);
vertices[3] = VertexWithColor(c + Offset, bottomRightColor);
vertices[4] = VertexWithColor(d + Offset, bottomLeftColor);
vertices[5] = VertexWithColor(a + Offset, topLeftColor);
parent.DrawRGBAVertices(vertices);
}
static Vertex VertexWithColor(float3 xyz, Color color)
{
color = Util.PremultiplyAlpha(color);
var cr = color.R / 255.0f;
var cg = color.G / 255.0f;
var cb = color.B / 255.0f;
var ca = color.A / 255.0f;
return new Vertex(xyz, cr, cg, cb, ca, 0, 0);
}
public void FillEllipse(float3 tl, float3 br, Color color, int vertices = 32)
{
// TODO: Create an ellipse polygon instead

View File

@@ -71,6 +71,17 @@ namespace OpenRA.Widgets
Game.Renderer.RgbaColorRenderer.FillRect(tl, br, c);
}
public static void FillRectWithColor(Rectangle r, Color topLeftColor, Color topRightColor, Color bottomRightColor, Color bottomLeftColor)
{
var tl = new float2(r.Left - 0.5f, r.Top - 0.5f);
var br = new float2(r.Right - 0.5f, r.Bottom - 0.5f);
var tr = new float3(br.X, tl.Y, 0);
var bl = new float3(tl.X, br.Y, 0);
Game.Renderer.RgbaColorRenderer.FillRect(tl, tr, br, bl, topLeftColor, topRightColor, bottomRightColor, bottomLeftColor);
}
public static void FillEllipseWithColor(Rectangle r, Color c)
{
var tl = new float2(r.Left, r.Top);