ADDED: DrawTriangleGradient()

This commit is contained in:
Ray
2026-04-27 11:37:48 +02:00
parent 620b21bfce
commit 636269f6af

View File

@ -1421,6 +1421,12 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f
// Draw a triangle
// NOTE: Vertex must be provided in counter-clockwise order
void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
{
DrawTriangleGradient(v1, v2, v3, color, color, color);
}
// Draw triangle with interpolated colors (vertex in counter-clockwise order!)
void DrawTriangleGradient(Vector2 v1, Vector2 v2, Vector2 v3, Color c1, Color c2, Color c3)
{
#if SUPPORT_QUADS_DRAW_MODE
rlSetTexture(GetShapesTexture().id);
@ -1428,17 +1434,20 @@ void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
rlBegin(RL_QUADS);
rlNormal3f(0.0f, 0.0f, 1.0f);
rlColor4ub(color.r, color.g, color.b, color.a);
rlColor4ub(c1.r, c1.g, c1.b, c1.a);
rlTexCoord2f(shapeRect.x/texShapes.width, shapeRect.y/texShapes.height);
rlVertex2f(v1.x, v1.y);
rlColor4ub(c2.r, c2.g, c2.b, c2.a);
rlTexCoord2f(shapeRect.x/texShapes.width, (shapeRect.y + shapeRect.height)/texShapes.height);
rlVertex2f(v2.x, v2.y);
rlColor4ub(c3.r, c3.g, c3.b, c3.a);
rlTexCoord2f((shapeRect.x + shapeRect.width)/texShapes.width, (shapeRect.y + shapeRect.height)/texShapes.height);
rlVertex2f(v3.x, v3.y);
rlColor4ub(c3.r, c3.g, c3.b, c3.a);
rlTexCoord2f((shapeRect.x + shapeRect.width)/texShapes.width, shapeRect.y/texShapes.height);
rlVertex2f(v3.x, v3.y);
rlEnd();
@ -1446,9 +1455,11 @@ void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
rlSetTexture(0);
#else
rlBegin(RL_TRIANGLES);
rlColor4ub(color.r, color.g, color.b, color.a);
rlColor4ub(c1.r, c1.g, c1.b, c1.a);
rlVertex2f(v1.x, v1.y);
rlColor4ub(c2.r, c2.g, c2.b, c2.a);
rlVertex2f(v2.x, v2.y);
rlColor4ub(c3.r, c3.g, c3.b, c3.a);
rlVertex2f(v3.x, v3.y);
rlEnd();
#endif