Table of Contents

Class PolygonDebugDrawExtensions

Namespace
Thunder.UnitsNET.Vectors.Geometry.MonoGame
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

polygon Polygon2

The polygon in world space.

sb SpriteBatch

The Microsoft.Xna.Framework.Graphics.SpriteBatch. Must be in an active Begin/End block.

pixel Texture2D

A 1×1 white pixel texture (see CreatePixelTexture(GraphicsDevice)).

worldToScreen Transform2

The world-to-screen Transform2.

color Color

Wireframe colour.

thickness float

Line 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

rect Rectangle2

The rectangle in world space.

sb SpriteBatch

The Microsoft.Xna.Framework.Graphics.SpriteBatch. Must be in an active Begin/End block.

pixel Texture2D

A 1×1 white pixel texture (see CreatePixelTexture(GraphicsDevice)).

worldToScreen Transform2

The world-to-screen Transform2.

color Color

Wireframe colour.

thickness float

Line 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

tri Triangle2

The triangle in world space.

sb SpriteBatch

The Microsoft.Xna.Framework.Graphics.SpriteBatch. Must be in an active Begin/End block.

pixel Texture2D

A 1×1 white pixel texture (see CreatePixelTexture(GraphicsDevice)).

worldToScreen Transform2

The world-to-screen Transform2.

color Color

Wireframe colour.

thickness float

Line 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

polygon Polygon2

The polygon in world space.

worldToScreen Transform2

The 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

rect Rectangle2

The rectangle in world space.

worldToScreen Transform2

The 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

tri Triangle2

The triangle in world space.

worldToScreen Transform2

The world-to-screen Transform2.

Returns

Vector2[]

Array of 3 screen-space Microsoft.Xna.Framework.Vector2 values.

latest ▼