Review gradient rectangle drawing
Added: DrawRectangleGradientV() Added: DrawRectangleGradientH()
This commit is contained in:
parent
639f41cf54
commit
4f9de9527f
@ -856,7 +856,8 @@ RLAPI void DrawCircleLines(int centerX, int centerY, float radius, Color color);
|
|||||||
RLAPI void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle
|
RLAPI void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle
|
||||||
RLAPI void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle
|
RLAPI void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle
|
||||||
RLAPI void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); // Draw a color-filled rectangle with pro parameters
|
RLAPI void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); // Draw a color-filled rectangle with pro parameters
|
||||||
RLAPI void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2); // Draw a gradient-filled rectangle
|
RLAPI void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2);// Draw a vertical-gradient-filled rectangle
|
||||||
|
RLAPI void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2);// Draw a horizontal-gradient-filled rectangle
|
||||||
RLAPI void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // Draw a gradient-filled rectangle with custom vertex colors
|
RLAPI void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // Draw a gradient-filled rectangle with custom vertex colors
|
||||||
RLAPI void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version)
|
RLAPI void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version)
|
||||||
RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline
|
RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline
|
||||||
|
20
src/shapes.c
20
src/shapes.c
@ -274,22 +274,22 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color
|
|||||||
rlDisableTexture();
|
rlDisableTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a gradient-filled rectangle
|
// Draw a vertical-gradient-filled rectangle
|
||||||
// NOTE: Gradient goes from bottom (color1) to top (color2)
|
// NOTE: Gradient goes from bottom (color1) to top (color2)
|
||||||
void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2)
|
void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2)
|
||||||
{
|
{
|
||||||
rlBegin(RL_TRIANGLES);
|
DrawRectangleGradientEx((Rectangle){ posX, posY, width, height }, color1, color2, color2, color1);
|
||||||
rlColor4ub(color1.r, color1.g, color1.b, color1.a); rlVertex2i(posX, posY);
|
}
|
||||||
rlColor4ub(color2.r, color2.g, color2.b, color2.a); rlVertex2i(posX, posY + height);
|
|
||||||
rlColor4ub(color2.r, color2.g, color2.b, color2.a); rlVertex2i(posX + width, posY + height);
|
|
||||||
|
|
||||||
rlColor4ub(color1.r, color1.g, color1.b, color1.a); rlVertex2i(posX, posY);
|
// Draw a horizontal-gradient-filled rectangle
|
||||||
rlColor4ub(color2.r, color2.g, color2.b, color2.a); rlVertex2i(posX + width, posY + height);
|
// NOTE: Gradient goes from bottom (color1) to top (color2)
|
||||||
rlColor4ub(color1.r, color1.g, color1.b, color1.a); rlVertex2i(posX + width, posY);
|
void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2)
|
||||||
rlEnd();
|
{
|
||||||
|
DrawRectangleGradientEx((Rectangle){ posX, posY, width, height }, color1, color1, color2, color2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a gradient-filled rectangle
|
// Draw a gradient-filled rectangle
|
||||||
|
// NOTE: Colors refer to corners, starting at top-lef corner and counter-clockwise
|
||||||
void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4)
|
void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4)
|
||||||
{
|
{
|
||||||
rlEnableTexture(GetTextureDefault().id); // Default white texture
|
rlEnableTexture(GetTextureDefault().id); // Default white texture
|
||||||
|
Loading…
Reference in New Issue
Block a user