public static void DrawHollowRect(this Batcher batcher, float x, float y, float width, float height, Color color, float thickness = 1) { var tl = new Vector2(x, y); var tr = new Vector2(x + width, y); var br = new Vector2(x + width, y + height); var bl = new Vector2(x, y + height); #if MG38 tl.Round(); tr.Round(); br.Round(); bl.Round(); #else tl = tl.Round(); tr = tr.Round(); br = br.Round(); bl = bl.Round(); #endif batcher.SetIgnoreRoundingDestinations(true); batcher.DrawLine(tl, tr, color, thickness); batcher.DrawLine(tr, br, color, thickness); batcher.DrawLine(br, bl, color, thickness); batcher.DrawLine(bl, tl, color, thickness); batcher.SetIgnoreRoundingDestinations(false); }
/// <summary> /// Draws a list of connected points /// </summary> /// <param name="points">The points to connect with lines</param> /// <param name="color">The color to use</param> /// <param name="thickness">The thickness of the lines</param> public static void DrawPoints(this Batcher batcher, Vector2[] points, Color color, float thickness = 1) { if (points.Length < 2) { return; } batcher.SetIgnoreRoundingDestinations(true); for (int i = 1; i < points.Length; i++) { DrawLine(batcher, points[i - 1], points[i], color, thickness); } batcher.SetIgnoreRoundingDestinations(false); }
/// <summary> /// Draws a list of connected points /// </summary> /// <param name="points">The points to connect with lines</param> /// <param name="color">The color to use</param> /// <param name="thickness">The thickness of the lines</param> public static void DrawPoints(this Batcher batcher, List <System.Numerics.Vector2> points, Color color, float thickness = 1) { if (points.Count < 2) { return; } batcher.SetIgnoreRoundingDestinations(true); for (int i = 1; i < points.Count; i++) { DrawLine(batcher, points[i - 1], points[i], color, thickness); } batcher.SetIgnoreRoundingDestinations(false); }
public static void DrawHollowRect(this Batcher batcher, float x, float y, float width, float height, Color color, float thickness = 1) { var tl = Vector2Ext.Round(new Vector2(x, y)); var tr = Vector2Ext.Round(new Vector2(x + width, y)); var br = Vector2Ext.Round(new Vector2(x + width, y + height)); var bl = Vector2Ext.Round(new Vector2(x, y + height)); batcher.SetIgnoreRoundingDestinations(true); batcher.DrawLine(tl, tr, color, thickness); batcher.DrawLine(tr, br, color, thickness); batcher.DrawLine(br, bl, color, thickness); batcher.DrawLine(bl, tl, color, thickness); batcher.SetIgnoreRoundingDestinations(false); }
public static void DrawPolygon(this Batcher batcher, Vector2 position, Vector2[] points, Color color, bool closePoly = true, float thickness = 1) { if (points.Length < 2) { return; } batcher.SetIgnoreRoundingDestinations(true); for (int i = 1; i < points.Length; i++) { DrawLine(batcher, position + points[i - 1], position + points[i], color, thickness); } if (closePoly) { DrawLine(batcher, position + points[points.Length - 1], position + points[0], color, thickness); } batcher.SetIgnoreRoundingDestinations(false); }
public static void DrawCircle(this Batcher batcher, Vector2 position, float radius, Color color, float thickness = 1f, int resolution = 12) { var last = Vector2.UnitX * radius; var lastP = Vector2Ext.Perpendicular(last); batcher.SetIgnoreRoundingDestinations(true); for (int i = 1; i <= resolution; i++) { var at = Mathf.AngleToVector(i * MathHelper.PiOver2 / resolution, radius); var atP = Vector2Ext.Perpendicular(at); DrawLine(batcher, position + last, position + at, color, thickness); DrawLine(batcher, position - last, position - at, color, thickness); DrawLine(batcher, position + lastP, position + atP, color, thickness); DrawLine(batcher, position - lastP, position - atP, color, thickness); last = at; lastP = atP; } batcher.SetIgnoreRoundingDestinations(false); }