using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace BouncyCatIsBouncy.Debugging { static class DrawingHelper { public static Texture2D CreateLineTexture(GraphicsDevice graphicss, int lineThickness, Color color) { Texture2D texture2D = new Texture2D(graphicss, 2, lineThickness + 2, 1, TextureUsage.None, SurfaceFormat.Color); int count = 2 * (lineThickness + 2); Color[] colorArray = new Color[count]; colorArray[0] = Color.TransparentWhite; colorArray[1] = Color.TransparentWhite; for (int i = 2; i < count - 2; i++) { colorArray[i] = color; } colorArray[count - 2] = Color.TransparentWhite; colorArray[count - 1] = Color.TransparentWhite; texture2D.SetData(colorArray); return texture2D; } public static Texture2D CreateCircleTexture(GraphicsDevice graphics, int radius, int borderWidth, Color borderColor) { Color color = Color.TransparentWhite; int y = -1; int diameter = radius + radius; Vector2 center = new Vector2(radius); Texture2D circle = new Texture2D(graphics, diameter, diameter, 1, TextureUsage.None, SurfaceFormat.Color); Color[] colors = new Color[diameter * diameter]; for (int i = 0; i < colors.Length; i++) { int x = i % diameter; if (x == 0) y += 1; Vector2 diff = new Vector2(x, y) - center; float length = diff.Length(); if (length > radius) { colors[i] = Color.TransparentBlack; } else if (length >= radius - borderWidth) { colors[i] = borderColor; } else { colors[i] = color; } } circle.SetData(colors); return circle; } } }