public static void DrawGrid(Canvas canvas, RectangleF bounds, float thickness, float lineEvery) { canvas.DrawLine(Color.Red, thickness, new Vector2(bounds.Left, 0), new Vector2(bounds.Right, 0)); canvas.DrawLine(Color.Green, thickness, new Vector2(0, bounds.Bottom), new Vector2(0, bounds.Top)); for (float x = -lineEvery; x >= bounds.Left; x -= lineEvery) canvas.DrawLine(Color.Gray, thickness, new Vector2(x, bounds.Bottom), new Vector2(x, bounds.Top)); for (float x = lineEvery; x <= bounds.Right; x += lineEvery) canvas.DrawLine(Color.Gray, thickness, new Vector2(x, bounds.Bottom), new Vector2(x, bounds.Top)); for (float y = -lineEvery; y >= bounds.Top; y -= lineEvery) canvas.DrawLine(Color.Gray, thickness, new Vector2(bounds.Left, y), new Vector2(bounds.Right, y)); for (float y = lineEvery; y <= bounds.Bottom; y += lineEvery) canvas.DrawLine(Color.Gray, thickness, new Vector2(bounds.Left, y), new Vector2(bounds.Right, y)); }
/// <summary> /// Enables camera bounds, so that the camera never leaves these bounds. /// </summary> /// <param name="bounds">The bounds for the camera.</param> public void EnableBounds(RectangleF bounds) { edgeBounds = bounds; centerBounds = bounds.Inflate(-Dimensions.X / 2, -Dimensions.Y / 2); applyBounds = true; }
public RectangleF Envelope(RectangleF other) { return new RectangleF(Math.Min(Left, other.Left), Math.Max(Right, other.Right), Math.Min(Top, other.Top), Math.Max(Bottom, other.Bottom)); }