summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2020-01-09 18:34:20 +0100
committerRay <[email protected]>2020-01-09 18:34:20 +0100
commite0d4cc314326f2c6d0390609df18d2e862c18a3a (patch)
tree6a0798304a316a8b9fe97dc92fe4751c7b16e14c
parentfcf15fe8c023a0308e1eec1a10dec09a748ccbe6 (diff)
downloadraylib-e0d4cc314326f2c6d0390609df18d2e862c18a3a.tar.gz
raylib-e0d4cc314326f2c6d0390609df18d2e862c18a3a.zip
ADDED: DrawPolyLines()
-rw-r--r--src/raylib.h1
-rw-r--r--src/shapes.c25
2 files changed, 26 insertions, 0 deletions
diff --git a/src/raylib.h b/src/raylib.h
index 018779a1..b3d5c144 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -1070,6 +1070,7 @@ RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color);
RLAPI void DrawTriangleFan(Vector2 *points, int numPoints, Color color); // Draw a triangle fan defined by points (first vertex is the center)
RLAPI void DrawTriangleStrip(Vector2 *points, int pointsCount, Color color); // Draw a triangle strip defined by points
RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version)
+RLAPI void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a polygon outline of n sides
RLAPI void SetShapesTexture(Texture2D texture, Rectangle source); // Define default texture used to draw shapes
diff --git a/src/shapes.c b/src/shapes.c
index bdc6ae0c..43037562 100644
--- a/src/shapes.c
+++ b/src/shapes.c
@@ -1346,6 +1346,31 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
rlPopMatrix();
}
+// Draw a polygon outline of n sides
+void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color)
+{
+ if (sides < 3) sides = 3;
+ float centralAngle = 0.0f;
+
+ if (rlCheckBufferLimit(3*(360/sides))) rlglDraw();
+
+ rlPushMatrix();
+ rlTranslatef(center.x, center.y, 0.0f);
+ rlRotatef(rotation, 0.0f, 0.0f, 1.0f);
+
+ rlBegin(RL_LINES);
+ for (int i = 0; i < sides; i++)
+ {
+ rlColor4ub(color.r, color.g, color.b, color.a);
+
+ rlVertex2f(sinf(DEG2RAD*centralAngle)*radius, cosf(DEG2RAD*centralAngle)*radius);
+ centralAngle += 360.0f/(float)sides;
+ rlVertex2f(sinf(DEG2RAD*centralAngle)*radius, cosf(DEG2RAD*centralAngle)*radius);
+ }
+ rlEnd();
+ rlPopMatrix();
+}
+
// Define default texture used to draw shapes
void SetShapesTexture(Texture2D texture, Rectangle source)
{