From e0d4cc314326f2c6d0390609df18d2e862c18a3a Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 9 Jan 2020 18:34:20 +0100 Subject: [PATCH] ADDED: DrawPolyLines() --- src/raylib.h | 1 + src/shapes.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) 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) {