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 segments to generate.
public static void DrawEllipse(Vector2 center, Vector2 radius, int segments)
{
DrawEllipse(center, radius.x, radius.y, segments, 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 segments to generate.
/// The color of the ellipse.
public static void DrawEllipse(Vector2 center, Vector2 radius, int segments, in Color color)
{
DrawEllipse(center, radius.x, radius.y, segments, 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 segments 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 segments, in Color color, float duration)
{
DrawEllipse(center, radius.x, radius.y, segments, 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 segments 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 segments, in Color color, float duration, bool depthTest)
{
DrawEllipse(center, radius.x, radius.y, segments, Vector2.zero, color, duration, depthTest);
}
///
/// Draws an ellipse.
///
/// The center point of the ellipse.
/// The radius of the ellipse.
/// The number of segments 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 segments, Vector2 offset, in Color color, float duration,
bool depthTest)
{
DrawEllipse(new EllipseF(center.x, center.y, radius.x, radius.y), segments, 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 segments to generate.
public static void DrawEllipse(Vector2 center, float radiusX, float radiusY, int segments)
{
DrawEllipse(center, radiusX, radiusY, segments, 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 segments to generate.
/// The color of the ellipse.
public static void DrawEllipse(Vector2 center, float radiusX, float radiusY, int segments, in Color color)
{
DrawEllipse(center, radiusX, radiusY, segments, 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 segments 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 segments, in Color color, float duration)
{
DrawEllipse(center, radiusX, radiusY, segments, 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 segments 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 segments, in Color color, float duration,
bool depthTest)
{
DrawEllipse(center, radiusX, radiusY, segments, 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 segments 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 segments, Vector2 offset, in Color color,
float duration, bool depthTest)
{
DrawEllipse(new EllipseF(center.x, center.y, radiusX, radiusY), segments, offset, color, duration, depthTest);
}
///
/// Draws an ellipse with the specified color.
///
/// The ellipse to draw.
/// The number of segments to generate.
public static void DrawEllipse(Ellipse ellipse, int segments)
{
DrawEllipse((EllipseF)ellipse, segments, Vector2.zero, Color.white, DefaultDrawDuration, DefaultDepthTest);
}
///
/// Draws an ellipse with the specified color.
///
/// The ellipse to draw.
/// The number of segments to generate.
/// The drawing offset of the ellipse.
public static void DrawEllipse(Ellipse ellipse, int segments, Vector2 offset)
{
DrawEllipse((EllipseF)ellipse, segments, offset, Color.white, DefaultDrawDuration, DefaultDepthTest);
}
///
/// Draws an ellipse with the specified color.
///
/// The ellipse to draw.
/// The number of segments to generate.
/// The color of the ellipse.
public static void DrawEllipse(Ellipse ellipse, int segments, in Color color)
{
DrawEllipse((EllipseF)ellipse, segments, Vector2.zero, color, DefaultDrawDuration, DefaultDepthTest);
}
///
/// Draws an ellipse with the specified color.
///
/// The ellipse to draw.
/// The number of segments to generate.
/// The drawing offset of the ellipse.
/// The color of the ellipse.
public static void DrawEllipse(Ellipse ellipse, int segments, Vector2 offset, in Color color)
{
DrawEllipse((EllipseF)ellipse, segments, offset, color, DefaultDrawDuration, DefaultDepthTest);
}
///
/// Draws an ellipse with the specified color and duration.
///
/// The ellipse to draw.
/// The number of segments 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 segments, in Color color, float duration)
{
DrawEllipse((EllipseF)ellipse, segments, Vector2.zero, color, duration, DefaultDepthTest);
}
///
/// Draws an ellipse with the specified color and duration.
///
/// The ellipse to draw.
/// The number of segments 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 segments, Vector2 offset, in Color color, float duration)
{
DrawEllipse((EllipseF)ellipse, segments, offset, color, duration, DefaultDepthTest);
}
///
/// Draws an ellipse with the specified color and duration.
///
/// The ellipse to draw.
/// The number of segments 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 segments, in Color color, float duration, bool depthTest)
{
DrawEllipse((EllipseF)ellipse, segments, Vector2.zero, color, duration, depthTest);
}
///
/// Draws an ellipse.
///
/// The ellipse to draw.
/// The number of segments 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 segments, Vector2 offset, in Color color, float duration, bool depthTest)
{
DrawEllipse((EllipseF)ellipse, segments, offset, color, duration, depthTest);
}
///
/// Draws an ellipse with the specified color.
///
/// The ellipse to draw.
/// The number of segments to generate.
public static void DrawEllipse(EllipseF ellipse, int segments)
{
DrawEllipse(ellipse, segments, Color.white, DefaultDrawDuration, DefaultDepthTest);
}
///
/// Draws an ellipse with the specified color.
///
/// The ellipse to draw.
/// The number of segments to generate.
/// The drawing offset of the ellipse.
public static void DrawEllipse(EllipseF ellipse, int segments, Vector2 offset)
{
DrawEllipse(ellipse, segments, offset, Color.white, DefaultDrawDuration, DefaultDepthTest);
}
///
/// Draws an ellipse with the specified color.
///
/// The ellipse to draw.
/// The number of segments to generate.
/// The color of the ellipse.
public static void DrawEllipse(EllipseF ellipse, int segments, in Color color)
{
DrawEllipse(ellipse, segments, Vector2.zero, color, DefaultDrawDuration, DefaultDepthTest);
}
///
/// Draws an ellipse with the specified color.
///
/// The ellipse to draw.
/// The number of segments to generate.
/// The drawing offset of the ellipse.
/// The color of the ellipse.
public static void DrawEllipse(EllipseF ellipse, int segments, Vector2 offset, in Color color)
{
DrawEllipse(ellipse, segments, offset, color, DefaultDrawDuration, DefaultDepthTest);
}
///
/// Draws an ellipse with the specified color and duration.
///
/// The ellipse to draw.
/// The number of segments 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 segments, in Color color, float duration)
{
DrawEllipse(ellipse, segments, Vector2.zero, color, duration, DefaultDepthTest);
}
///
/// Draws an ellipse with the specified color and duration.
///
/// The ellipse to draw.
/// The number of segments 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 segments, Vector2 offset, in Color color, float duration)
{
DrawEllipse(ellipse, segments, offset, color, duration, DefaultDepthTest);
}
///
/// Draws an ellipse with the specified color and duration.
///
/// The ellipse to draw.
/// The number of segments 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 segments, in Color color, float duration, bool depthTest)
{
DrawEllipse(ellipse, segments, Vector2.zero, color, duration, depthTest);
}
///
/// Draws an ellipse.
///
/// The ellipse to draw.
/// The number of segments 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 segments, Vector2 offset, in Color color, float duration, bool depthTest)
{
DrawPolygon(CreateEllipse(ellipse.HorizontalRadius, ellipse.VerticalRadius, segments), offset, color, duration,
depthTest);
}
private static PolygonF CreateEllipse(float radiusX, float radiusY, int segments)
{
const float max = 2.0f * MathF.PI;
float step = max / segments;
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);
}
}