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,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); DrawRectangle( (int)rec.x, (int)(rec.y + lineThick), lineThick, (int)(rec.height - lineThick*2), color);
} }
// Draw rectangle with rounded edges. // Draw rectangle with rounded edges
void DrawRoundedRect(Rectangle rec, float roundness, int segments, Color color) void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color)
{ {
// Not a rounded rectangle // 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); DrawRectangleRec(rec, color);
return; return;
@@ -711,7 +711,7 @@ void DrawRoundedRect(Rectangle rec, float roundness, int segments, Color color)
if (roundness >= 1.0f) roundness = 1.0f; if (roundness >= 1.0f) roundness = 1.0f;
// Calculate corner radius // 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; if (radius <= 0.0f) return;
// Calculate number of segments to use for the corners // 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 + 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 {(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 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 };
@@ -888,10 +889,11 @@ void DrawRoundedRect(Rectangle rec, float roundness, int segments, Color color)
#endif #endif
} }
// Draw rounded rectangle outline // Draw rectangle with rounded edges outline
void DrawRoundedRectLines(Rectangle rec, float roundness, int segments, int lineThick, Color color) 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 // Not a rounded rectangle
if (roundness <= 0.0f) 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; if (roundness >= 1.0f) roundness = 1.0f;
// Calculate corner radius // 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; if (radius <= 0.0f) return;
// Calculate number of segments to use for the corners // 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 {(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 { rec.x, (float)(rec.y + rec.height) - innerRadius}, {rec.x, (float)rec.y + innerRadius} // P14, P15
}; };
const Vector2 centers[4] = { 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 + 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 {(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 }; const float angles[4] = { 180.0f, 90.0f, 0.0f, 270.0f };
if (lineThick > 1) if (lineThick > 1)
{ {
#if defined(SUPPORT_QUADS_DRAW_MODE) #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 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); rlBegin(RL_QUADS);
// Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner // 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
@@ -973,6 +978,7 @@ void DrawRoundedRectLines(Rectangle rec, float roundness, int segments, int line
angle += stepLength; angle += stepLength;
} }
} }
// Upper rectangle // Upper rectangle
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f(point[0].x, point[0].y); rlVertex2f(point[0].x, point[0].y);
@@ -1004,12 +1010,15 @@ void DrawRoundedRectLines(Rectangle rec, float roundness, int segments, int line
rlEnd(); rlEnd();
#else #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 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); rlBegin(RL_TRIANGLES);
// Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner // 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]; float angle = angles[k];
const Vector2 center = centers[k]; const Vector2 center = centers[k];
for (int i = 0; i < segments; i++) for (int i = 0; i < segments; i++)
{ {
rlColor4ub(color.r, color.g, color.b, color.a); 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 // 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 if (rlCheckBufferLimit(8*segments + 4*2)) rlglDraw(); // 4 corners with 2 vertices for each segment + 4 rectangles with 2 vertices each
rlBegin(RL_LINES); rlBegin(RL_LINES);
// Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner // 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]; float angle = angles[k];
const Vector2 center = centers[k]; const Vector2 center = centers[k];
for (int i = 0; i < segments; i++) for (int i = 0; i < segments; i++)
{ {
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);