using UnityEngine; using X10D.Drawing; namespace X10D.Unity; public static partial class DebugEx { /// /// Draws an ellipse with the specified color. /// /// The center point of the ellipse. /// The radius of the ellipse. /// The number of sides to generate. public static void DrawEllipse(Vector2 center, Vector2 radius, int sides) { DrawEllipse(center, radius.x, radius.y, sides, Color.white, DefaultDrawDuration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color. /// /// The center point of the ellipse. /// The radius of the ellipse. /// The number of sides to generate. /// The color of the ellipse. public static void DrawEllipse(Vector2 center, Vector2 radius, int sides, in Color color) { DrawEllipse(center, radius.x, radius.y, sides, color, DefaultDrawDuration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color and duration. /// /// The center point of the ellipse. /// The radius of the ellipse. /// The number of sides to generate. /// The color of the ellipse. /// /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. /// public static void DrawEllipse(Vector2 center, Vector2 radius, int sides, in Color color, float duration) { DrawEllipse(center, radius.x, radius.y, sides, Vector2.zero, color, duration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color and duration. /// /// The center point of the ellipse. /// The radius of the ellipse. /// The number of sides to generate. /// The color of the ellipse. /// /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. /// /// /// if depth test should be applied; otherwise, . Passing /// will have the ellipse be obscured by objects closer to the camera. /// public static void DrawEllipse(Vector2 center, Vector2 radius, int sides, in Color color, float duration, bool depthTest) { DrawEllipse(center, radius.x, radius.y, sides, Vector2.zero, color, duration, depthTest); } /// /// Draws an ellipse. /// /// The center point of the ellipse. /// The radius of the ellipse. /// The number of sides to generate. /// The drawing offset of the ellipse. /// The color of the ellipse. /// /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. /// /// /// if depth test should be applied; otherwise, . Passing /// will have the ellipse be obscured by objects closer to the camera. /// public static void DrawEllipse(Vector2 center, Vector2 radius, int sides, Vector2 offset, in Color color, float duration, bool depthTest) { DrawEllipse(new EllipseF(center.x, center.y, radius.x, radius.y), sides, offset, color, duration, depthTest); } /// /// Draws an ellipse with the specified color. /// /// The center point of the ellipse. /// The horizontal radius of the ellipse. /// The vertical radius of the ellipse. /// The number of sides to generate. public static void DrawEllipse(Vector2 center, float radiusX, float radiusY, int sides) { DrawEllipse(center, radiusX, radiusY, sides, Color.white, DefaultDrawDuration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color. /// /// The center point of the ellipse. /// The horizontal radius of the ellipse. /// The vertical radius of the ellipse. /// The number of sides to generate. /// The color of the ellipse. public static void DrawEllipse(Vector2 center, float radiusX, float radiusY, int sides, in Color color) { DrawEllipse(center, radiusX, radiusY, sides, color, DefaultDrawDuration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color and duration. /// /// The center point of the ellipse. /// The horizontal radius of the ellipse. /// The vertical radius of the ellipse. /// The number of sides to generate. /// The color of the ellipse. /// /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. /// public static void DrawEllipse(Vector2 center, float radiusX, float radiusY, int sides, in Color color, float duration) { DrawEllipse(center, radiusX, radiusY, sides, Vector2.zero, color, duration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color and duration. /// /// The center point of the ellipse. /// The horizontal radius of the ellipse. /// The vertical radius of the ellipse. /// The number of sides to generate. /// The color of the ellipse. /// /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. /// /// /// if depth test should be applied; otherwise, . Passing /// will have the ellipse be obscured by objects closer to the camera. /// public static void DrawEllipse(Vector2 center, float radiusX, float radiusY, int sides, in Color color, float duration, bool depthTest) { DrawEllipse(center, radiusX, radiusY, sides, Vector2.zero, color, duration, depthTest); } /// /// Draws an ellipse. /// /// The center point of the ellipse. /// The horizontal radius of the ellipse. /// The vertical radius of the ellipse. /// The number of sides to generate. /// The drawing offset of the ellipse. /// The color of the ellipse. /// /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. /// /// /// if depth test should be applied; otherwise, . Passing /// will have the ellipse be obscured by objects closer to the camera. /// public static void DrawEllipse(Vector2 center, float radiusX, float radiusY, int sides, Vector2 offset, in Color color, float duration, bool depthTest) { DrawEllipse(new EllipseF(center.x, center.y, radiusX, radiusY), sides, offset, color, duration, depthTest); } /// /// Draws an ellipse with the specified color. /// /// The ellipse to draw. /// The number of sides to generate. public static void DrawEllipse(Ellipse ellipse, int sides) { DrawEllipse((EllipseF)ellipse, sides, Vector2.zero, Color.white, DefaultDrawDuration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color. /// /// The ellipse to draw. /// The number of sides to generate. /// The drawing offset of the ellipse. public static void DrawEllipse(Ellipse ellipse, int sides, Vector2 offset) { DrawEllipse((EllipseF)ellipse, sides, offset, Color.white, DefaultDrawDuration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color. /// /// The ellipse to draw. /// The number of sides to generate. /// The color of the ellipse. public static void DrawEllipse(Ellipse ellipse, int sides, in Color color) { DrawEllipse((EllipseF)ellipse, sides, Vector2.zero, color, DefaultDrawDuration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color. /// /// The ellipse to draw. /// The number of sides to generate. /// The drawing offset of the ellipse. /// The color of the ellipse. public static void DrawEllipse(Ellipse ellipse, int sides, Vector2 offset, in Color color) { DrawEllipse((EllipseF)ellipse, sides, offset, color, DefaultDrawDuration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color and duration. /// /// The ellipse to draw. /// The number of sides to generate. /// The color of the ellipse. /// /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. /// public static void DrawEllipse(Ellipse ellipse, int sides, in Color color, float duration) { DrawEllipse((EllipseF)ellipse, sides, Vector2.zero, color, duration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color and duration. /// /// The ellipse to draw. /// The number of sides to generate. /// The drawing offset of the ellipse. /// The color of the ellipse. /// /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. /// public static void DrawEllipse(Ellipse ellipse, int sides, Vector2 offset, in Color color, float duration) { DrawEllipse((EllipseF)ellipse, sides, offset, color, duration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color and duration. /// /// The ellipse to draw. /// The number of sides to generate. /// The color of the ellipse. /// /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. /// /// /// if depth test should be applied; otherwise, . Passing /// will have the ellipse be obscured by objects closer to the camera. /// public static void DrawEllipse(Ellipse ellipse, int sides, in Color color, float duration, bool depthTest) { DrawEllipse((EllipseF)ellipse, sides, Vector2.zero, color, duration, depthTest); } /// /// Draws an ellipse. /// /// The ellipse to draw. /// The number of sides to generate. /// The drawing offset of the ellipse. /// The color of the ellipse. /// /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. /// /// /// if depth test should be applied; otherwise, . Passing /// will have the ellipse be obscured by objects closer to the camera. /// public static void DrawEllipse(Ellipse ellipse, int sides, Vector2 offset, in Color color, float duration, bool depthTest) { DrawEllipse((EllipseF)ellipse, sides, offset, color, duration, depthTest); } /// /// Draws an ellipse with the specified color. /// /// The ellipse to draw. /// The number of sides to generate. public static void DrawEllipse(EllipseF ellipse, int sides) { DrawEllipse(ellipse, sides, Color.white, DefaultDrawDuration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color. /// /// The ellipse to draw. /// The number of sides to generate. /// The drawing offset of the ellipse. public static void DrawEllipse(EllipseF ellipse, int sides, Vector2 offset) { DrawEllipse(ellipse, sides, offset, Color.white, DefaultDrawDuration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color. /// /// The ellipse to draw. /// The number of sides to generate. /// The color of the ellipse. public static void DrawEllipse(EllipseF ellipse, int sides, in Color color) { DrawEllipse(ellipse, sides, Vector2.zero, color, DefaultDrawDuration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color. /// /// The ellipse to draw. /// The number of sides to generate. /// The drawing offset of the ellipse. /// The color of the ellipse. public static void DrawEllipse(EllipseF ellipse, int sides, Vector2 offset, in Color color) { DrawEllipse(ellipse, sides, offset, color, DefaultDrawDuration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color and duration. /// /// The ellipse to draw. /// The number of sides to generate. /// The color of the ellipse. /// /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. /// public static void DrawEllipse(EllipseF ellipse, int sides, in Color color, float duration) { DrawEllipse(ellipse, sides, Vector2.zero, color, duration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color and duration. /// /// The ellipse to draw. /// The number of sides to generate. /// The drawing offset of the ellipse. /// The color of the ellipse. /// /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. /// public static void DrawEllipse(EllipseF ellipse, int sides, Vector2 offset, in Color color, float duration) { DrawEllipse(ellipse, sides, offset, color, duration, DefaultDepthTest); } /// /// Draws an ellipse with the specified color and duration. /// /// The ellipse to draw. /// The number of sides to generate. /// The color of the ellipse. /// /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. /// /// /// if depth test should be applied; otherwise, . Passing /// will have the ellipse be obscured by objects closer to the camera. /// public static void DrawEllipse(EllipseF ellipse, int sides, in Color color, float duration, bool depthTest) { DrawEllipse(ellipse, sides, Vector2.zero, color, duration, depthTest); } /// /// Draws an ellipse. /// /// The ellipse to draw. /// The number of sides to generate. /// The drawing offset of the ellipse. /// The color of the ellipse. /// /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. /// /// /// if depth test should be applied; otherwise, . Passing /// will have the ellipse be obscured by objects closer to the camera. /// public static void DrawEllipse(EllipseF ellipse, int sides, Vector2 offset, in Color color, float duration, bool depthTest) { DrawPolygon(CreateEllipse(ellipse.HorizontalRadius, ellipse.VerticalRadius, sides), offset, color, duration, depthTest); } private static PolygonF CreateEllipse(float radiusX, float radiusY, int sides) { const float max = 2.0f * MathF.PI; float step = max / sides; var points = new List(); for (var theta = 0f; theta < max; theta += step) { float x = radiusX * MathF.Cos(theta); float y = radiusY * MathF.Sin(theta); points.Add(new System.Numerics.Vector2(x, y)); } return new PolygonF(points); } }