Review merged PR formatting

Removed trail spaces
This commit is contained in:
Ray 2019-04-04 13:50:28 +02:00
parent 6ecd8249bc
commit 3e1e7d740f

View file

@ -698,21 +698,21 @@ 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;
}
if(roundness >= 1.0f) roundness = 1.0f;
if (roundness >= 1.0f) roundness = 1.0f;
// Calculate corner radius
float radius = rec.width > rec.height ? (rec.height*roundness)/2 : (rec.width*roundness)/2;
if(radius <= 0.0f) return;
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
if (segments < 4)
@ -752,15 +752,16 @@ 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 };
const float angles[4] = { 180.0f, 90.0f, 0.0f, 270.0f };
#if defined(SUPPORT_QUADS_DRAW_MODE)
if (rlCheckBufferLimit(16*segments/2 + 5*4)) rlglDraw();
rlBegin(RL_QUADS);
// Draw all of the 4 corners: [1] Upper Left Corner, [3] Upper Right Corner, [5] Lower Right Corner, [7] Lower Left Corner
for(int k = 0; k < 4; ++k) // Hope the compiler is smart enough to unroll this loop
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];
@ -826,7 +827,7 @@ void DrawRoundedRect(Rectangle rec, float roundness, int segments, Color color)
rlBegin(RL_TRIANGLES);
// Draw all of the 4 corners: [1] Upper Left Corner, [3] Upper Right Corner, [5] Lower Right Corner, [7] Lower Left Corner
for(int k = 0; k < 4; ++k) // Hope the compiler is smart enough to unroll this loop
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];
@ -888,22 +889,23 @@ 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;
if (lineThick < 0) lineThick = 0;
// Not a rounded rectangle
if(roundness <= 0.0f )
if (roundness <= 0.0f)
{
DrawRectangleLinesEx((Rectangle){rec.x-lineThick, rec.y-lineThick, rec.width+2*lineThick, rec.height+2*lineThick}, lineThick, color);
return;
}
if(roundness >= 1.0f) roundness = 1.0f;
if (roundness >= 1.0f) roundness = 1.0f;
// Calculate corner radius
float radius = rec.width > rec.height ? (rec.height*roundness)/2 : (rec.width*roundness)/2;
if(radius <= 0.0f) return;
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
if (segments < 4)
@ -946,19 +948,22 @@ 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)
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
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];
@ -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
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
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);
@ -1083,11 +1095,11 @@ void DrawRoundedRectLines(Rectangle rec, float roundness, int segments, int line
}
}
// And now the remaining 4 lines
for(int i=0; i<8; i+=2)
for(int i = 0; i < 8; i += 2)
{
rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f(point[i].x, point[i].y);
rlVertex2f(point[i+1].x, point[i+1].y);
rlVertex2f(point[i + 1].x, point[i + 1].y);
}
rlEnd();
}