@@ -888,14 +888,13 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
888888// Draw rectangle with rounded edges
889889void DrawRectangleRoundedLines (Rectangle rec , float roundness , int segments , Color color )
890890{
891- // NOTE: For line thicknes <=1.0f using RL_LINES, otherwise using RL_QUADS/RL_TRIANGLES
892891 DrawRectangleRoundedLinesEx (rec , roundness , segments , 1.0f , color );
893892}
894893
895894// Draw rectangle with rounded edges outline with line thickness
896895void DrawRectangleRoundedLinesEx (Rectangle rec , float roundness , int segments , float thick , Color color )
897896{
898- if (thick < 0 ) thick = 0 ;
897+ if (thick <= 0 ) return ;
899898
900899 // Not a rounded rectangle
901900 if (roundness <= 0.0f )
@@ -966,176 +965,145 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f
966965
967966 const float angles [4 ] = { 180.0f , 270.0f , 0.0f , 90.0f };
968967
969- if (thick > 1 )
970- {
971968#if SUPPORT_QUADS_DRAW_MODE
972- rlSetTexture (GetShapesTexture ().id );
973- Rectangle shapeRect = GetShapesTextureRectangle ();
969+ rlSetTexture (GetShapesTexture ().id );
970+ Rectangle shapeRect = GetShapesTextureRectangle ();
974971
975- rlBegin (RL_QUADS );
972+ rlBegin (RL_QUADS );
976973
977- // Draw all the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
978- for (int k = 0 ; k < 4 ; ++ k ) // Hope the compiler is smart enough to unroll this loop
974+ // Draw all the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
975+ for (int k = 0 ; k < 4 ; ++ k ) // Hope the compiler is smart enough to unroll this loop
976+ {
977+ float angle = angles [k ];
978+ const Vector2 center = centers [k ];
979+ for (int i = 0 ; i < segments ; i ++ )
979980 {
980- float angle = angles [k ];
981- const Vector2 center = centers [k ];
982- for (int i = 0 ; i < segments ; i ++ )
983- {
984- rlColor4ub (color .r , color .g , color .b , color .a );
981+ rlColor4ub (color .r , color .g , color .b , color .a );
985982
986- rlTexCoord2f (shapeRect .x /texShapes .width , shapeRect .y /texShapes .height );
987- rlVertex2f (center .x + cosf (DEG2RAD * angle )* innerRadius , center .y + sinf (DEG2RAD * angle )* innerRadius );
983+ rlTexCoord2f (shapeRect .x /texShapes .width , shapeRect .y /texShapes .height );
984+ rlVertex2f (center .x + cosf (DEG2RAD * angle )* innerRadius , center .y + sinf (DEG2RAD * angle )* innerRadius );
988985
989- rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , shapeRect .y /texShapes .height );
990- rlVertex2f (center .x + cosf (DEG2RAD * (angle + stepLength ))* innerRadius , center .y + sinf (DEG2RAD * (angle + stepLength ))* innerRadius );
986+ rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , shapeRect .y /texShapes .height );
987+ rlVertex2f (center .x + cosf (DEG2RAD * (angle + stepLength ))* innerRadius , center .y + sinf (DEG2RAD * (angle + stepLength ))* innerRadius );
991988
992- rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
993- rlVertex2f (center .x + cosf (DEG2RAD * (angle + stepLength ))* outerRadius , center .y + sinf (DEG2RAD * (angle + stepLength ))* outerRadius );
989+ rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
990+ rlVertex2f (center .x + cosf (DEG2RAD * (angle + stepLength ))* outerRadius , center .y + sinf (DEG2RAD * (angle + stepLength ))* outerRadius );
994991
995- rlTexCoord2f (shapeRect .x /texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
996- rlVertex2f (center .x + cosf (DEG2RAD * angle )* outerRadius , center .y + sinf (DEG2RAD * angle )* outerRadius );
992+ rlTexCoord2f (shapeRect .x /texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
993+ rlVertex2f (center .x + cosf (DEG2RAD * angle )* outerRadius , center .y + sinf (DEG2RAD * angle )* outerRadius );
997994
998- angle += stepLength ;
999- }
995+ angle += stepLength ;
1000996 }
997+ }
1001998
1002- // Upper rectangle
1003- rlColor4ub (color .r , color .g , color .b , color .a );
1004- rlTexCoord2f (shapeRect .x /texShapes .width , shapeRect .y /texShapes .height );
1005- rlVertex2f (point [0 ].x , point [0 ].y );
1006- rlTexCoord2f (shapeRect .x /texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1007- rlVertex2f (point [8 ].x , point [8 ].y );
1008- rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1009- rlVertex2f (point [9 ].x , point [9 ].y );
1010- rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , shapeRect .y /texShapes .height );
1011- rlVertex2f (point [1 ].x , point [1 ].y );
999+ // Upper rectangle
1000+ rlColor4ub (color .r , color .g , color .b , color .a );
1001+ rlTexCoord2f (shapeRect .x /texShapes .width , shapeRect .y /texShapes .height );
1002+ rlVertex2f (point [0 ].x , point [0 ].y );
1003+ rlTexCoord2f (shapeRect .x /texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1004+ rlVertex2f (point [8 ].x , point [8 ].y );
1005+ rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1006+ rlVertex2f (point [9 ].x , point [9 ].y );
1007+ rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , shapeRect .y /texShapes .height );
1008+ rlVertex2f (point [1 ].x , point [1 ].y );
10121009
1013- // Right rectangle
1014- rlColor4ub (color .r , color .g , color .b , color .a );
1015- rlTexCoord2f (shapeRect .x /texShapes .width , shapeRect .y /texShapes .height );
1016- rlVertex2f (point [2 ].x , point [2 ].y );
1017- rlTexCoord2f (shapeRect .x /texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1018- rlVertex2f (point [10 ].x , point [10 ].y );
1019- rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1020- rlVertex2f (point [11 ].x , point [11 ].y );
1021- rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , shapeRect .y /texShapes .height );
1022- rlVertex2f (point [3 ].x , point [3 ].y );
1010+ // Right rectangle
1011+ rlColor4ub (color .r , color .g , color .b , color .a );
1012+ rlTexCoord2f (shapeRect .x /texShapes .width , shapeRect .y /texShapes .height );
1013+ rlVertex2f (point [2 ].x , point [2 ].y );
1014+ rlTexCoord2f (shapeRect .x /texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1015+ rlVertex2f (point [10 ].x , point [10 ].y );
1016+ rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1017+ rlVertex2f (point [11 ].x , point [11 ].y );
1018+ rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , shapeRect .y /texShapes .height );
1019+ rlVertex2f (point [3 ].x , point [3 ].y );
10231020
1024- // Lower rectangle
1025- rlColor4ub (color .r , color .g , color .b , color .a );
1026- rlTexCoord2f (shapeRect .x /texShapes .width , shapeRect .y /texShapes .height );
1027- rlVertex2f (point [13 ].x , point [13 ].y );
1028- rlTexCoord2f (shapeRect .x /texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1029- rlVertex2f (point [5 ].x , point [5 ].y );
1030- rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1031- rlVertex2f (point [4 ].x , point [4 ].y );
1032- rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , shapeRect .y /texShapes .height );
1033- rlVertex2f (point [12 ].x , point [12 ].y );
1021+ // Lower rectangle
1022+ rlColor4ub (color .r , color .g , color .b , color .a );
1023+ rlTexCoord2f (shapeRect .x /texShapes .width , shapeRect .y /texShapes .height );
1024+ rlVertex2f (point [13 ].x , point [13 ].y );
1025+ rlTexCoord2f (shapeRect .x /texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1026+ rlVertex2f (point [5 ].x , point [5 ].y );
1027+ rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1028+ rlVertex2f (point [4 ].x , point [4 ].y );
1029+ rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , shapeRect .y /texShapes .height );
1030+ rlVertex2f (point [12 ].x , point [12 ].y );
10341031
1035- // Left rectangle
1036- rlColor4ub (color .r , color .g , color .b , color .a );
1037- rlTexCoord2f (shapeRect .x /texShapes .width , shapeRect .y /texShapes .height );
1038- rlVertex2f (point [15 ].x , point [15 ].y );
1039- rlTexCoord2f (shapeRect .x /texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1040- rlVertex2f (point [7 ].x , point [7 ].y );
1041- rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1042- rlVertex2f (point [6 ].x , point [6 ].y );
1043- rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , shapeRect .y /texShapes .height );
1044- rlVertex2f (point [14 ].x , point [14 ].y );
1032+ // Left rectangle
1033+ rlColor4ub (color .r , color .g , color .b , color .a );
1034+ rlTexCoord2f (shapeRect .x /texShapes .width , shapeRect .y /texShapes .height );
1035+ rlVertex2f (point [15 ].x , point [15 ].y );
1036+ rlTexCoord2f (shapeRect .x /texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1037+ rlVertex2f (point [7 ].x , point [7 ].y );
1038+ rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , (shapeRect .y + shapeRect .height )/texShapes .height );
1039+ rlVertex2f (point [6 ].x , point [6 ].y );
1040+ rlTexCoord2f ((shapeRect .x + shapeRect .width )/texShapes .width , shapeRect .y /texShapes .height );
1041+ rlVertex2f (point [14 ].x , point [14 ].y );
10451042
1046- rlEnd ();
1047- rlSetTexture (0 );
1043+ rlEnd ();
1044+ rlSetTexture (0 );
10481045#else
1049- rlBegin (RL_TRIANGLES );
1046+ rlBegin (RL_TRIANGLES );
10501047
1051- // Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
1052- for (int k = 0 ; k < 4 ; ++ k ) // Hope the compiler is smart enough to unroll this loop
1053- {
1054- float angle = angles [k ];
1055- const Vector2 center = centers [k ];
1048+ // Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
1049+ for (int k = 0 ; k < 4 ; ++ k ) // Hope the compiler is smart enough to unroll this loop
1050+ {
1051+ float angle = angles [k ];
1052+ const Vector2 center = centers [k ];
10561053
1057- for (int i = 0 ; i < segments ; i ++ )
1058- {
1059- rlColor4ub (color .r , color .g , color .b , color .a );
1054+ for (int i = 0 ; i < segments ; i ++ )
1055+ {
1056+ rlColor4ub (color .r , color .g , color .b , color .a );
10601057
1061- rlVertex2f (center .x + cosf (DEG2RAD * angle )* innerRadius , center .y + sinf (DEG2RAD * angle )* innerRadius );
1062- rlVertex2f (center .x + cosf (DEG2RAD * (angle + stepLength ))* innerRadius , center .y + sinf (DEG2RAD * (angle + stepLength ))* innerRadius );
1063- rlVertex2f (center .x + cosf (DEG2RAD * angle )* outerRadius , center .y + sinf (DEG2RAD * angle )* outerRadius );
1058+ rlVertex2f (center .x + cosf (DEG2RAD * angle )* innerRadius , center .y + sinf (DEG2RAD * angle )* innerRadius );
1059+ rlVertex2f (center .x + cosf (DEG2RAD * (angle + stepLength ))* innerRadius , center .y + sinf (DEG2RAD * (angle + stepLength ))* innerRadius );
1060+ rlVertex2f (center .x + cosf (DEG2RAD * angle )* outerRadius , center .y + sinf (DEG2RAD * angle )* outerRadius );
10641061
1065- rlVertex2f (center .x + cosf (DEG2RAD * (angle + stepLength ))* innerRadius , center .y + sinf (DEG2RAD * (angle + stepLength ))* innerRadius );
1066- rlVertex2f (center .x + cosf (DEG2RAD * (angle + stepLength ))* outerRadius , center .y + sinf (DEG2RAD * (angle + stepLength ))* outerRadius );
1067- rlVertex2f (center .x + cosf (DEG2RAD * angle )* outerRadius , center .y + sinf (DEG2RAD * angle )* outerRadius );
1062+ rlVertex2f (center .x + cosf (DEG2RAD * (angle + stepLength ))* innerRadius , center .y + sinf (DEG2RAD * (angle + stepLength ))* innerRadius );
1063+ rlVertex2f (center .x + cosf (DEG2RAD * (angle + stepLength ))* outerRadius , center .y + sinf (DEG2RAD * (angle + stepLength ))* outerRadius );
1064+ rlVertex2f (center .x + cosf (DEG2RAD * angle )* outerRadius , center .y + sinf (DEG2RAD * angle )* outerRadius );
10681065
1069- angle += stepLength ;
1070- }
1066+ angle += stepLength ;
10711067 }
1068+ }
10721069
1073- // Upper rectangle
1074- rlColor4ub (color .r , color .g , color .b , color .a );
1075- rlVertex2f (point [0 ].x , point [0 ].y );
1076- rlVertex2f (point [8 ].x , point [8 ].y );
1077- rlVertex2f (point [9 ].x , point [9 ].y );
1078- rlVertex2f (point [1 ].x , point [1 ].y );
1079- rlVertex2f (point [0 ].x , point [0 ].y );
1080- rlVertex2f (point [9 ].x , point [9 ].y );
1081-
1082- // Right rectangle
1083- rlColor4ub (color .r , color .g , color .b , color .a );
1084- rlVertex2f (point [10 ].x , point [10 ].y );
1085- rlVertex2f (point [11 ].x , point [11 ].y );
1086- rlVertex2f (point [3 ].x , point [3 ].y );
1087- rlVertex2f (point [2 ].x , point [2 ].y );
1088- rlVertex2f (point [10 ].x , point [10 ].y );
1089- rlVertex2f (point [3 ].x , point [3 ].y );
1090-
1091- // Lower rectangle
1092- rlColor4ub (color .r , color .g , color .b , color .a );
1093- rlVertex2f (point [13 ].x , point [13 ].y );
1094- rlVertex2f (point [5 ].x , point [5 ].y );
1095- rlVertex2f (point [4 ].x , point [4 ].y );
1096- rlVertex2f (point [12 ].x , point [12 ].y );
1097- rlVertex2f (point [13 ].x , point [13 ].y );
1098- rlVertex2f (point [4 ].x , point [4 ].y );
1099-
1100- // Left rectangle
1101- rlColor4ub (color .r , color .g , color .b , color .a );
1102- rlVertex2f (point [7 ].x , point [7 ].y );
1103- rlVertex2f (point [6 ].x , point [6 ].y );
1104- rlVertex2f (point [14 ].x , point [14 ].y );
1105- rlVertex2f (point [15 ].x , point [15 ].y );
1106- rlVertex2f (point [7 ].x , point [7 ].y );
1107- rlVertex2f (point [14 ].x , point [14 ].y );
1108- rlEnd ();
1109- #endif
1110- }
1111- else
1112- {
1113- // Use LINES to draw the outline
1114- rlBegin (RL_LINES );
1115- // Draw all the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
1116- for (int k = 0 ; k < 4 ; ++ k ) // Hope the compiler is smart enough to unroll this loop
1117- {
1118- float angle = angles [k ];
1119- const Vector2 center = centers [k ];
1070+ // Upper rectangle
1071+ rlColor4ub (color .r , color .g , color .b , color .a );
1072+ rlVertex2f (point [0 ].x , point [0 ].y );
1073+ rlVertex2f (point [8 ].x , point [8 ].y );
1074+ rlVertex2f (point [9 ].x , point [9 ].y );
1075+ rlVertex2f (point [1 ].x , point [1 ].y );
1076+ rlVertex2f (point [0 ].x , point [0 ].y );
1077+ rlVertex2f (point [9 ].x , point [9 ].y );
11201078
1121- for ( int i = 0 ; i < segments ; i ++ )
1122- {
1123- rlColor4ub ( color . r , color . g , color . b , color . a );
1124- rlVertex2f (center . x + cosf ( DEG2RAD * angle ) * outerRadius , center . y + sinf ( DEG2RAD * angle ) * outerRadius );
1125- rlVertex2f (center . x + cosf ( DEG2RAD * ( angle + stepLength )) * outerRadius , center . y + sinf ( DEG2RAD * ( angle + stepLength )) * outerRadius );
1126- angle += stepLength ;
1127- }
1128- }
1079+ // Right rectangle
1080+ rlColor4ub ( color . r , color . g , color . b , color . a );
1081+ rlVertex2f ( point [ 10 ]. x , point [ 10 ]. y );
1082+ rlVertex2f (point [ 11 ]. x , point [ 11 ]. y );
1083+ rlVertex2f (point [ 3 ]. x , point [ 3 ]. y );
1084+ rlVertex2f ( point [ 2 ]. x , point [ 2 ]. y ) ;
1085+ rlVertex2f ( point [ 10 ]. x , point [ 10 ]. y );
1086+ rlVertex2f ( point [ 3 ]. x , point [ 3 ]. y );
11291087
1130- // And now the remaining 4 lines
1131- for (int i = 0 ; i < 8 ; i += 2 )
1132- {
1133- rlColor4ub (color .r , color .g , color .b , color .a );
1134- rlVertex2f (point [i ].x , point [i ].y );
1135- rlVertex2f (point [i + 1 ].x , point [i + 1 ].y );
1136- }
1137- rlEnd ();
1138- }
1088+ // Lower rectangle
1089+ rlColor4ub (color .r , color .g , color .b , color .a );
1090+ rlVertex2f (point [13 ].x , point [13 ].y );
1091+ rlVertex2f (point [5 ].x , point [5 ].y );
1092+ rlVertex2f (point [4 ].x , point [4 ].y );
1093+ rlVertex2f (point [12 ].x , point [12 ].y );
1094+ rlVertex2f (point [13 ].x , point [13 ].y );
1095+ rlVertex2f (point [4 ].x , point [4 ].y );
1096+
1097+ // Left rectangle
1098+ rlColor4ub (color .r , color .g , color .b , color .a );
1099+ rlVertex2f (point [7 ].x , point [7 ].y );
1100+ rlVertex2f (point [6 ].x , point [6 ].y );
1101+ rlVertex2f (point [14 ].x , point [14 ].y );
1102+ rlVertex2f (point [15 ].x , point [15 ].y );
1103+ rlVertex2f (point [7 ].x , point [7 ].y );
1104+ rlVertex2f (point [14 ].x , point [14 ].y );
1105+ rlEnd ();
1106+ #endif
11391107}
11401108
11411109// Draw a polygon of n sides
0 commit comments