Review merged PR formatting
Removed trail spaces
This commit is contained in:
parent
6ecd8249bc
commit
3e1e7d740f
1 changed files with 182 additions and 170 deletions
26
src/shapes.c
26
src/shapes.c
|
@ -698,11 +698,11 @@ void DrawRectangleLinesEx(Rectangle rec, int lineThick, Color color)
|
|||
DrawRectangle( (int)rec.x, (int)(rec.y + lineThick), lineThick, (int)(rec.height - lineThick*2), color);
|
||||
}
|
||||
|
||||
// Draw rectangle with rounded edges.
|
||||
void DrawRoundedRect(Rectangle rec, float roundness, int segments, Color color)
|
||||
// Draw rectangle with rounded edges
|
||||
void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color)
|
||||
{
|
||||
// Not a rounded rectangle
|
||||
if(roundness <= 0.0f || rec.width < 1 || rec.height < 1 )
|
||||
if ((roundness <= 0.0f) || (rec.width < 1) || (rec.height < 1 ))
|
||||
{
|
||||
DrawRectangleRec(rec, color);
|
||||
return;
|
||||
|
@ -711,7 +711,7 @@ void DrawRoundedRect(Rectangle rec, float roundness, int segments, Color color)
|
|||
if (roundness >= 1.0f) roundness = 1.0f;
|
||||
|
||||
// Calculate corner radius
|
||||
float radius = rec.width > rec.height ? (rec.height*roundness)/2 : (rec.width*roundness)/2;
|
||||
float radius = (rec.width > rec.height)? (rec.height*roundness)/2 : (rec.width*roundness)/2;
|
||||
if (radius <= 0.0f) return;
|
||||
|
||||
// Calculate number of segments to use for the corners
|
||||
|
@ -752,6 +752,7 @@ void DrawRoundedRect(Rectangle rec, float roundness, int segments, Color color)
|
|||
{(float)rec.x + radius, (float)rec.y + radius}, {(float)(rec.x + rec.width) - radius, (float)rec.y + radius}, // P8, P9
|
||||
{(float)(rec.x + rec.width) - radius, (float)(rec.y + rec.height) - radius}, {(float)rec.x + radius, (float)(rec.y + rec.height) - radius} // P10, P11
|
||||
};
|
||||
|
||||
const Vector2 centers[4] = { point[8], point[9], point[10], point[11] };
|
||||
const float angles[4] = { 180.0f, 90.0f, 0.0f, 270.0f };
|
||||
|
||||
|
@ -888,10 +889,11 @@ void DrawRoundedRect(Rectangle rec, float roundness, int segments, Color color)
|
|||
#endif
|
||||
}
|
||||
|
||||
// Draw rounded rectangle outline
|
||||
void DrawRoundedRectLines(Rectangle rec, float roundness, int segments, int lineThick, Color color)
|
||||
// Draw rectangle with rounded edges outline
|
||||
void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int lineThick, Color color)
|
||||
{
|
||||
if (lineThick < 0) lineThick = 0;
|
||||
|
||||
// Not a rounded rectangle
|
||||
if (roundness <= 0.0f)
|
||||
{
|
||||
|
@ -902,7 +904,7 @@ void DrawRoundedRectLines(Rectangle rec, float roundness, int segments, int line
|
|||
if (roundness >= 1.0f) roundness = 1.0f;
|
||||
|
||||
// Calculate corner radius
|
||||
float radius = rec.width > rec.height ? (rec.height*roundness)/2 : (rec.width*roundness)/2;
|
||||
float radius = (rec.width > rec.height)? (rec.height*roundness)/2 : (rec.width*roundness)/2;
|
||||
if (radius <= 0.0f) return;
|
||||
|
||||
// Calculate number of segments to use for the corners
|
||||
|
@ -946,16 +948,19 @@ void DrawRoundedRectLines(Rectangle rec, float roundness, int segments, int line
|
|||
{(float)(rec.x + rec.width) - innerRadius, rec.y + rec.height}, {(float)rec.x + innerRadius, rec.y + rec.height}, // P12, P13
|
||||
{ rec.x, (float)(rec.y + rec.height) - innerRadius}, {rec.x, (float)rec.y + innerRadius} // P14, P15
|
||||
};
|
||||
|
||||
const Vector2 centers[4] = {
|
||||
{(float)rec.x + innerRadius, (float)rec.y + innerRadius}, {(float)(rec.x + rec.width) - innerRadius, (float)rec.y + innerRadius}, // P16, P17
|
||||
{(float)(rec.x + rec.width) - innerRadius, (float)(rec.y + rec.height) - innerRadius}, {(float)rec.x + innerRadius, (float)(rec.y + rec.height) - innerRadius} // P18, P19
|
||||
};
|
||||
|
||||
const float angles[4] = { 180.0f, 90.0f, 0.0f, 270.0f };
|
||||
|
||||
if (lineThick > 1)
|
||||
{
|
||||
#if defined(SUPPORT_QUADS_DRAW_MODE)
|
||||
if (rlCheckBufferLimit(4*4*segments + 4*4)) rlglDraw(); // 4 corners with 4 vertices for each segment + 4 rectangles with 4 vertices each
|
||||
|
||||
rlBegin(RL_QUADS);
|
||||
// Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
|
||||
for (int k = 0; k < 4; ++k) // Hope the compiler is smart enough to unroll this loop
|
||||
|
@ -973,6 +978,7 @@ void DrawRoundedRectLines(Rectangle rec, float roundness, int segments, int line
|
|||
angle += stepLength;
|
||||
}
|
||||
}
|
||||
|
||||
// Upper rectangle
|
||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||
rlVertex2f(point[0].x, point[0].y);
|
||||
|
@ -1004,12 +1010,15 @@ void DrawRoundedRectLines(Rectangle rec, float roundness, int segments, int line
|
|||
rlEnd();
|
||||
#else
|
||||
if (rlCheckBufferLimit(4*6*segments + 4*6)) rlglDraw(); // 4 corners with 6(2*3) vertices for each segment + 4 rectangles with 6 vertices each
|
||||
|
||||
rlBegin(RL_TRIANGLES);
|
||||
|
||||
// Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
|
||||
for (int k = 0; k < 4; ++k) // Hope the compiler is smart enough to unroll this loop
|
||||
{
|
||||
float angle = angles[k];
|
||||
const Vector2 center = centers[k];
|
||||
|
||||
for (int i = 0; i < segments; i++)
|
||||
{
|
||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||
|
@ -1068,12 +1077,15 @@ void DrawRoundedRectLines(Rectangle rec, float roundness, int segments, int line
|
|||
{
|
||||
// Use LINES to draw the outline
|
||||
if (rlCheckBufferLimit(8*segments + 4*2)) rlglDraw(); // 4 corners with 2 vertices for each segment + 4 rectangles with 2 vertices each
|
||||
|
||||
rlBegin(RL_LINES);
|
||||
|
||||
// Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
|
||||
for (int k = 0; k < 4; ++k) // Hope the compiler is smart enough to unroll this loop
|
||||
{
|
||||
float angle = angles[k];
|
||||
const Vector2 center = centers[k];
|
||||
|
||||
for (int i = 0; i < segments; i++)
|
||||
{
|
||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue