diff options
| author | raysan5 <[email protected]> | 2017-03-05 21:04:07 +0100 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2017-03-05 21:04:07 +0100 |
| commit | 59038bae96bf8e9ae96ce3432ddbde96590f4642 (patch) | |
| tree | d0f62d5ad956f2e2055a8e64d00ca9eb31a11966 /src/shapes.c | |
| parent | aaf9c648d3de5454878531d44abd3c8a663af769 (diff) | |
| download | raylib-59038bae96bf8e9ae96ce3432ddbde96590f4642.tar.gz raylib-59038bae96bf8e9ae96ce3432ddbde96590f4642.zip | |
Added function: DrawLineEx()
Supports line thickness
Diffstat (limited to 'src/shapes.c')
| -rw-r--r-- | src/shapes.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/shapes.c b/src/shapes.c index a42b0551..9cbe1da4 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -103,6 +103,36 @@ void DrawLineV(Vector2 startPos, Vector2 endPos, Color color) rlEnd(); } +// Draw a line defining thickness +void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color) +{ + float dx = endPos.x - startPos.x; + float dy = endPos.y - startPos.y; + + float d = sqrtf(dx*dx + dy*dy); + float angle = asinf(dy/d); + + rlEnableTexture(GetDefaultTexture().id); + + rlPushMatrix(); + rlTranslatef((float)startPos.x, (float)startPos.y, 0); + rlRotatef(-RAD2DEG*angle, 0, 0, 1); + rlTranslatef(0, -thick/2.0f, 0); + + rlBegin(RL_QUADS); + rlColor4ub(color.r, color.g, color.b, color.a); + rlNormal3f(0.0f, 0.0f, 1.0f); + + rlVertex2f(0.0f, 0.0f); + rlVertex2f(0.0f, thick); + rlVertex2f(d, thick); + rlVertex2f(d, 0.0f); + rlEnd(); + rlPopMatrix(); + + rlDisableTexture(); +} + // Draw a color-filled circle void DrawCircle(int centerX, int centerY, float radius, Color color) { |
