diff options
| author | Ray <[email protected]> | 2017-09-26 09:13:16 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-09-26 09:13:16 +0200 |
| commit | 4a63e5dfb3006483cace85c8161d12057a9e8488 (patch) | |
| tree | 53f1ca68df7c2d398a157a825c21fc4ea704f07d /src/shapes.c | |
| parent | 7ca90d87f9fa6f399d3316df347c63baf0eb675d (diff) | |
| parent | 5ace947a809d32d0177334933b0709b3164a79d5 (diff) | |
| download | raylib-4a63e5dfb3006483cace85c8161d12057a9e8488.tar.gz raylib-4a63e5dfb3006483cace85c8161d12057a9e8488.zip | |
Merge pull request #360 from raysan5/develop
Integrate Develop branch
Diffstat (limited to 'src/shapes.c')
| -rw-r--r-- | src/shapes.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/shapes.c b/src/shapes.c index 0e544718..8c7f2419 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -289,6 +289,53 @@ void DrawRectangleGradient(int posX, int posY, int width, int height, Color colo rlEnd(); } +// Draw a gradient-filled rectangle +void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4) +{ + rlEnableTexture(GetTextureDefault().id); // Default white texture + + rlBegin(RL_QUADS); + rlNormal3f(0.0f, 0.0f, 1.0f); + + rlColor4ub(col1.r, col1.g, col1.b, col1.a); + rlTexCoord2f(0.0f, 0.0f); + rlVertex2f(rec.x, rec.y); + + rlColor4ub(col2.r, col2.g, col2.b, col2.a); + rlTexCoord2f(0.0f, 1.0f); + rlVertex2f(rec.x, rec.y + rec.height); + + rlColor4ub(col3.r, col3.g, col3.b, col3.a); + rlTexCoord2f(1.0f, 1.0f); + rlVertex2f(rec.x + rec.width, rec.y + rec.height); + + rlColor4ub(col4.r, col4.g, col4.b, col4.a); + rlTexCoord2f(1.0f, 0.0f); + rlVertex2f(rec.x + rec.width, rec.y); + rlEnd(); + + // Draw rectangle using font texture white character + /* + rlTexCoord2f((float)GetDefaultFont().chars[95].rec.x/GetDefaultFont().texture.width, + (float)GetDefaultFont().chars[95].rec.y/GetDefaultFont().texture.height); + rlVertex2f(rec.x, rec.y); + + rlTexCoord2f((float)GetDefaultFont().chars[95].rec.x/GetDefaultFont().texture.width, + (float)(GetDefaultFont().chars[95].rec.y + GetDefaultFont().chars[95].rec.height)/GetDefaultFont().texture.height); + rlVertex2f(rec.x, rec.y + rec.height); + + rlTexCoord2f((float)(GetDefaultFont().chars[95].rec.x + GetDefaultFont().chars[95].rec.width)/GetDefaultFont().texture.width, + (float)(GetDefaultFont().chars[95].rec.y + GetDefaultFont().chars[95].rec.height)/GetDefaultFont().texture.height); + rlVertex2f(rec.x + rec.width, rec.y + rec.height); + + rlTexCoord2f((float)(GetDefaultFont().chars[95].rec.x + GetDefaultFont().chars[95].rec.width)/GetDefaultFont().texture.width, + (float)GetDefaultFont().chars[95].rec.y/GetDefaultFont().texture.height); + rlVertex2f(rec.x + rec.width, rec.y); + */ + + rlDisableTexture(); +} + // Draw a color-filled rectangle (Vector version) // NOTE: On OpenGL 3.3 and ES2 we use QUADS to avoid drawing order issues (view rlglDraw) void DrawRectangleV(Vector2 position, Vector2 size, Color color) @@ -362,6 +409,14 @@ void DrawRectangleLines(int posX, int posY, int width, int height, Color color) } } +// Draw rectangle using text character (char: 127) +// NOTE: Useful to avoid changing to default white texture +void DrawRectangleT(int posX, int posY, int width, int height, Color color) +{ + DrawTexturePro(GetDefaultFont().texture, GetDefaultFont().chars[95].rec, + (Rectangle){ posX, posY, width, height }, (Vector2){ 0, 0 }, 0.0f, color); +} + // Draw a triangle void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color) { |
