Clone wiki

2D XNA Primitives / DrawLine

DrawLine

Draws a line from point (x1, y1) to point (x2, y2)

public static void DrawLine(this SpriteBatch spriteBatch, float x1, float y1, float x2, float y2, Color color, float thickness = 1f)
Parameter NameDescription
spriteBatchThe destination drawing surface
x1The X coord of the first point
y1The Y coord of the first point
x2The X coord of the second point
y2The Y coord of the second point
colorThe color to use
thicknessThe thickness of the line. Default = 1f

Draws a line from point1 to point2

public static void DrawLine(this SpriteBatch spriteBatch, Vector2 point1, Vector2 point2, Color color, float thickness = 1f)
Parameter NameDescription
spriteBatchThe destination drawing surface
point1The first point
point2The second point
colorThe color to use
thicknessThe thickness of the line. Default = 1f

Draws a line starting from point, and extending a certain number of pixels at a given angle

public static void DrawLine(this SpriteBatch spriteBatch, Vector2 point, float length, float angle, Color color, float thickness = 1f)
Parameter NameDescription
spriteBatchThe destination drawing surface
pointThe starting point
lengthThe length of the line
angleThe angle of this line from the starting point
colorThe color to use
thicknessThe thickness of the line. Default = 1f

Updated