public static void FilledCenteredRect(PrimitivBuffer target, Vector2 center, Vector2 size) { target.Clear(); target.DrawType = PrimitiveType.Quads; target.Vertex(center.X - size.X, center.Y - size.Y); target.Vertex(center.X + size.X, center.Y - size.Y); target.Vertex(center.X + size.X, center.Y + size.Y); target.Vertex(center.X - size.X, center.Y + size.Y); }
public static void FilledRect(PrimitivBuffer target, float minimumX, float minimumY, float maxiumX, float maxiumY) { target.Clear(); target.DrawType = PrimitiveType.Quads; target.Vertex(minimumX, minimumY); target.Vertex(maxiumX, minimumY); target.Vertex(maxiumX, maxiumY); target.Vertex(minimumX, maxiumY); }
public static void OutlineRect(PrimitivBuffer target, float minimumX, float minimumY, float maxiumX, float maxiumY, float width) { target.Clear(); target.OutlineWidth = width; target.DrawType = PrimitiveType.LineLoop; target.Vertex(minimumX, minimumY); target.Vertex(minimumX, maxiumY); target.Vertex(maxiumX, maxiumY); target.Vertex(maxiumX, minimumY); }
public static void OutlineCenteredRect(PrimitivBuffer target, Vector2 center, Vector2 size, float width) { target.Clear(); target.OutlineWidth = width; target.DrawType = PrimitiveType.LineLoop; target.Vertex(center.X - size.X, center.Y - size.Y); target.Vertex(center.X - size.X, center.Y + size.Y); target.Vertex(center.X + size.X, center.Y + size.Y); target.Vertex(center.X + size.X, center.Y - size.Y); }
private static void AddQuad(PrimitivBuffer target, Vector2 minV, Vector2 maxV, Vector2 minT, Vector2 maxT) { target.Vertex(minV.X, minV.Y); target.UVs.Add(new Vector2(minT.X, maxT.Y)); target.Vertex(maxV.X, minV.Y); target.UVs.Add(new Vector2(maxT.X, maxT.Y)); target.Vertex(maxV.X, maxV.Y); target.UVs.Add(new Vector2(maxT.X, minT.Y)); target.Vertex(minV.X, maxV.Y); target.UVs.Add(new Vector2(minT.X, minT.Y)); }
public static void FilledGradientRect(PrimitivBuffer target, Vector2 center, Vector2 size, Color maxColor, Color minColor, bool horizontal) { target.Clear(); target.DrawType = PrimitiveType.Quads; if (horizontal) { target.Colors.Add(minColor); target.Vertex(center.X - size.X, center.Y + size.Y); target.Colors.Add(minColor); target.Vertex(center.X - size.X, center.Y - size.Y); target.Colors.Add(maxColor); target.Vertex(center.X + size.X, center.Y - size.Y); target.Colors.Add(maxColor); target.Vertex(center.X + size.X, center.Y + size.Y); } else { target.Colors.Add(minColor); target.Vertex(center.X - size.X, center.Y - size.Y); target.Colors.Add(minColor); target.Vertex(center.X + size.X, center.Y - size.Y); target.Colors.Add(maxColor); target.Vertex(center.X + size.X, center.Y + size.Y); target.Colors.Add(maxColor); target.Vertex(center.X - size.X, center.Y + size.Y); } }
public static void TexturedRect(PrimitivBuffer target, float minimumX, float minimumY, float maxiumX, float maxiumY, Vector2 uvScale, bool reverseU = false, bool revserseV = false) { target.Clear(); target.DrawType = PrimitiveType.Quads; target.Vertex(minimumX, minimumY); target.UVs.Add(new Vector2(reverseU ? uvScale.X : 0, revserseV ? 0 : uvScale.Y)); target.Vertex(maxiumX, minimumY); target.UVs.Add(new Vector2(reverseU ? 0 : uvScale.X, revserseV ? 0 : uvScale.Y)); target.Vertex(maxiumX, maxiumY); target.UVs.Add(new Vector2(reverseU ? 0 : uvScale.X, revserseV ? uvScale.Y : 0)); target.Vertex(minimumX, maxiumY); target.UVs.Add(new Vector2(reverseU ? uvScale.X : 0, revserseV ? uvScale.Y : 0)); }
public static void StretchedH(PrimitivBuffer target, RelativeRect rect) { var origin = rect.GetPixelOrigin(); var size = rect.GetPixelSize(); if (size.X <= size.Y) { ShapeBuffer.TexturedRect(target, rect); return; } float halfHeight = size.Y * 0.5f; target.Clear(); target.DrawType = PrimitiveType.Quads; float minimumX = origin.X; float minimumY = origin.Y; float maxiumX = origin.X + halfHeight; float maxiumY = origin.Y + size.Y; float minU = 0; float maxU = 0.5f; float minV = 0; float maxV = 1; // left side target.Vertex(minimumX, minimumY); target.UVs.Add(new Vector2(minU, maxV)); target.Vertex(maxiumX, minimumY); target.UVs.Add(new Vector2(maxU, maxV)); target.Vertex(maxiumX, maxiumY); target.UVs.Add(new Vector2(maxU, minV)); target.Vertex(minimumX, maxiumY); target.UVs.Add(new Vector2(minU, minV)); // middle minimumX = origin.X + halfHeight; minimumY = origin.Y; maxiumX = origin.X + size.X - halfHeight; maxiumY = origin.Y + size.Y; minU = 0.5f; maxU = 0.5f; minV = 0; maxV = 1; target.Vertex(minimumX, minimumY); target.UVs.Add(new Vector2(minU, maxV)); target.Vertex(maxiumX, minimumY); target.UVs.Add(new Vector2(maxU, maxV)); target.Vertex(maxiumX, maxiumY); target.UVs.Add(new Vector2(maxU, minV)); target.Vertex(minimumX, maxiumY); target.UVs.Add(new Vector2(minU, minV)); // right minimumX = origin.X + size.X - halfHeight; minimumY = origin.Y; maxiumX = origin.X + size.X; maxiumY = origin.Y + size.Y; minU = 0.5f; maxU = 1f; minV = 0; maxV = 1; target.Vertex(minimumX, minimumY); target.UVs.Add(new Vector2(minU, maxV)); target.Vertex(maxiumX, minimumY); target.UVs.Add(new Vector2(maxU, maxV)); target.Vertex(maxiumX, maxiumY); target.UVs.Add(new Vector2(maxU, minV)); target.Vertex(minimumX, maxiumY); target.UVs.Add(new Vector2(minU, minV)); }