Class PolygonDebugDrawExtensions
- Assembly
- Thunder.UnitsNET.Vectors.Geometry.MonoGame.dll
DebugDraw extension methods for polygon-based shapes: Rectangle2, Triangle2, and Polygon2.
public static class PolygonDebugDrawExtensions
- Inheritance
-
PolygonDebugDrawExtensions
- Inherited Members
Remarks
All GetDebugScreenVertices methods are internal and convert world-space vertices to
screen-space Microsoft.Xna.Framework.Vector2 arrays using a world-to-screen Transform2.
The public DebugDraw methods render the wireframe outline using
DrawLine(SpriteBatch, Texture2D, Vector2, Vector2, Color, float).
Methods
DebugDraw(Polygon2, SpriteBatch, Texture2D, Transform2, Color, float)
Draws the wireframe outline of polygon on the Microsoft.Xna.Framework.Graphics.SpriteBatch.
public static void DebugDraw(this Polygon2 polygon, SpriteBatch sb, Texture2D pixel, Transform2 worldToScreen, Color color, float thickness = 1)
Parameters
polygonPolygon2The polygon in world space.
sbSpriteBatchThe Microsoft.Xna.Framework.Graphics.SpriteBatch. Must be in an active
Begin/Endblock.pixelTexture2DA 1×1 white pixel texture (see CreatePixelTexture(GraphicsDevice)).
worldToScreenTransform2The world-to-screen Transform2.
colorColorWireframe colour.
thicknessfloatLine thickness in pixels. Defaults to 1.
DebugDraw(Rectangle2, SpriteBatch, Texture2D, Transform2, Color, float)
Draws the wireframe outline of rect as four lines on the
Microsoft.Xna.Framework.Graphics.SpriteBatch.
public static void DebugDraw(this Rectangle2 rect, SpriteBatch sb, Texture2D pixel, Transform2 worldToScreen, Color color, float thickness = 1)
Parameters
rectRectangle2The rectangle in world space.
sbSpriteBatchThe Microsoft.Xna.Framework.Graphics.SpriteBatch. Must be in an active
Begin/Endblock.pixelTexture2DA 1×1 white pixel texture (see CreatePixelTexture(GraphicsDevice)).
worldToScreenTransform2The world-to-screen Transform2.
colorColorWireframe colour.
thicknessfloatLine thickness in pixels. Defaults to 1.
Examples
// doctest-compile-only
myRect.DebugDraw(spriteBatch, pixel, worldToScreen, Color.Green);
DebugDraw(Triangle2, SpriteBatch, Texture2D, Transform2, Color, float)
Draws the wireframe outline of tri as three lines on the
Microsoft.Xna.Framework.Graphics.SpriteBatch.
public static void DebugDraw(this Triangle2 tri, SpriteBatch sb, Texture2D pixel, Transform2 worldToScreen, Color color, float thickness = 1)
Parameters
triTriangle2The triangle in world space.
sbSpriteBatchThe Microsoft.Xna.Framework.Graphics.SpriteBatch. Must be in an active
Begin/Endblock.pixelTexture2DA 1×1 white pixel texture (see CreatePixelTexture(GraphicsDevice)).
worldToScreenTransform2The world-to-screen Transform2.
colorColorWireframe colour.
thicknessfloatLine thickness in pixels. Defaults to 1.
GetDebugScreenVertices(Polygon2, Transform2)
Converts all vertices of polygon to screen-space positions,
preserving vertex order.
public static Vector2[] GetDebugScreenVertices(this Polygon2 polygon, Transform2 worldToScreen)
Parameters
polygonPolygon2The polygon in world space.
worldToScreenTransform2The world-to-screen Transform2.
Returns
- Vector2[]
Array of screen-space Microsoft.Xna.Framework.Vector2 values, one per vertex.
GetDebugScreenVertices(Rectangle2, Transform2)
Converts the four corners of rect to screen-space vertices in
[TopLeft, TopRight, BottomRight, BottomLeft] order.
public static Vector2[] GetDebugScreenVertices(this Rectangle2 rect, Transform2 worldToScreen)
Parameters
rectRectangle2The rectangle in world space.
worldToScreenTransform2The world-to-screen Transform2.
Returns
- Vector2[]
Array of 4 screen-space Microsoft.Xna.Framework.Vector2 values.
GetDebugScreenVertices(Triangle2, Transform2)
Converts the three vertices (A, B, C) of tri to screen-space positions.
public static Vector2[] GetDebugScreenVertices(this Triangle2 tri, Transform2 worldToScreen)
Parameters
triTriangle2The triangle in world space.
worldToScreenTransform2The world-to-screen Transform2.
Returns
- Vector2[]
Array of 3 screen-space Microsoft.Xna.Framework.Vector2 values.