|
|
@ -182,36 +182,19 @@ void DrawCircle(int centerX, int centerY, float radius, Color color) |
|
|
|
DrawCircleV((Vector2){ (float)centerX, (float)centerY }, radius, color); |
|
|
|
} |
|
|
|
|
|
|
|
// Draw a gradient-filled circle |
|
|
|
// NOTE: Gradient goes from center (color1) to border (color2) |
|
|
|
void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2) |
|
|
|
{ |
|
|
|
if (rlCheckBufferLimit(3*36)) rlglDraw(); |
|
|
|
|
|
|
|
rlBegin(RL_TRIANGLES); |
|
|
|
for (int i = 0; i < 360; i += 10) |
|
|
|
{ |
|
|
|
rlColor4ub(color1.r, color1.g, color1.b, color1.a); |
|
|
|
rlVertex2i(centerX, centerY); |
|
|
|
rlColor4ub(color2.r, color2.g, color2.b, color2.a); |
|
|
|
rlVertex2f(centerX + sinf(DEG2RAD*i)*radius, centerY + cosf(DEG2RAD*i)*radius); |
|
|
|
rlColor4ub(color2.r, color2.g, color2.b, color2.a); |
|
|
|
rlVertex2f(centerX + sinf(DEG2RAD*(i + 10))*radius, centerY + cosf(DEG2RAD*(i + 10))*radius); |
|
|
|
} |
|
|
|
rlEnd(); |
|
|
|
} |
|
|
|
|
|
|
|
// Draw a color-filled circle (Vector version) |
|
|
|
// NOTE: On OpenGL 3.3 and ES2 we use QUADS to avoid drawing order issues (view rlglDraw) |
|
|
|
void DrawCircleV(Vector2 center, float radius, Color color) |
|
|
|
// Draw a piece of a circle |
|
|
|
// TODO: Support better angle resolution (now limited to CIRCLE_SECTOR_LENGTH) |
|
|
|
void DrawCircleSector(Vector2 center, float radius, int startAngle, int endAngle, Color color) |
|
|
|
{ |
|
|
|
#define CIRCLE_SECTOR_LENGTH 10 |
|
|
|
|
|
|
|
#if defined(SUPPORT_QUADS_DRAW_MODE) |
|
|
|
if (rlCheckBufferLimit(4*(36/2))) rlglDraw(); |
|
|
|
if (rlCheckBufferLimit(4*((360/CIRCLE_SECTOR_LENGTH)/2))) rlglDraw(); |
|
|
|
|
|
|
|
rlEnableTexture(GetShapesTexture().id); |
|
|
|
|
|
|
|
rlBegin(RL_QUADS); |
|
|
|
for (int i = mi">0; i < 360; i += 20) |
|
|
|
for (int i = startAngle; i < endAngle; i += CIRCLE_SECTOR_LENGTH*2) |
|
|
|
{ |
|
|
|
rlColor4ub(color.r, color.g, color.b, color.a); |
|
|
|
|
|
|
@ -222,30 +205,56 @@ void DrawCircleV(Vector2 center, float radius, Color color) |
|
|
|
rlVertex2f(center.x + sinf(DEG2RAD*i)*radius, center.y + cosf(DEG2RAD*i)*radius); |
|
|
|
|
|
|
|
rlTexCoord2f((recTexShapes.x + recTexShapes.width)/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height); |
|
|
|
rlVertex2f(center.x + sinf(DEG2RAD*(i + mi">10))*radius, center.y + cosf(DEG2RAD*(i + mi">10))*radius); |
|
|
|
rlVertex2f(center.x + sinf(DEG2RAD*(i + n">CIRCLE_SECTOR_LENGTH))*radius, center.y + cosf(DEG2RAD*(i + n">CIRCLE_SECTOR_LENGTH))*radius); |
|
|
|
|
|
|
|
rlTexCoord2f((recTexShapes.x + recTexShapes.width)/texShapes.width, recTexShapes.y/texShapes.height); |
|
|
|
rlVertex2f(center.x + sinf(DEG2RAD*(i + 20))*radius, center.y + cosf(DEG2RAD*(i + 20))*radius); |
|
|
|
rlVertex2f(center.x + sinf(DEG2RAD*(i + n">CIRCLE_SECTOR_LENGTH*2))*radius, center.y + cosf(DEG2RAD*(i + n">CIRCLE_SECTOR_LENGTH*2))*radius); |
|
|
|
} |
|
|
|
rlEnd(); |
|
|
|
|
|
|
|
rlDisableTexture(); |
|
|
|
#else |
|
|
|
if (rlCheckBufferLimit(3*(36/2))) rlglDraw(); |
|
|
|
if (rlCheckBufferLimit(3*(p">(360/CIRCLE_SECTOR_LENGTH)/2))) rlglDraw(); |
|
|
|
|
|
|
|
rlBegin(RL_TRIANGLES); |
|
|
|
for (int i = mi">0; i < 360; i += mi">10) |
|
|
|
for (int i = n">startAngle; i < endAngle; i += n">CIRCLE_SECTOR_LENGTH) |
|
|
|
{ |
|
|
|
rlColor4ub(color.r, color.g, color.b, color.a); |
|
|
|
|
|
|
|
rlVertex2f(center.x, center.y); |
|
|
|
rlVertex2f(center.x + sinf(DEG2RAD*i)*radius, center.y + cosf(DEG2RAD*i)*radius); |
|
|
|
rlVertex2f(center.x + sinf(DEG2RAD*(i + mi">10))*radius, center.y + cosf(DEG2RAD*(i + mi">10))*radius); |
|
|
|
rlVertex2f(center.x + sinf(DEG2RAD*(i + n">CIRCLE_SECTOR_LENGTH))*radius, center.y + cosf(DEG2RAD*(i + n">CIRCLE_SECTOR_LENGTH))*radius); |
|
|
|
} |
|
|
|
rlEnd(); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
// Draw a gradient-filled circle |
|
|
|
// NOTE: Gradient goes from center (color1) to border (color2) |
|
|
|
void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2) |
|
|
|
{ |
|
|
|
if (rlCheckBufferLimit(3*36)) rlglDraw(); |
|
|
|
|
|
|
|
rlBegin(RL_TRIANGLES); |
|
|
|
for (int i = 0; i < 360; i += 10) |
|
|
|
{ |
|
|
|
rlColor4ub(color1.r, color1.g, color1.b, color1.a); |
|
|
|
rlVertex2i(centerX, centerY); |
|
|
|
rlColor4ub(color2.r, color2.g, color2.b, color2.a); |
|
|
|
rlVertex2f(centerX + sinf(DEG2RAD*i)*radius, centerY + cosf(DEG2RAD*i)*radius); |
|
|
|
rlColor4ub(color2.r, color2.g, color2.b, color2.a); |
|
|
|
rlVertex2f(centerX + sinf(DEG2RAD*(i + 10))*radius, centerY + cosf(DEG2RAD*(i + 10))*radius); |
|
|
|
} |
|
|
|
rlEnd(); |
|
|
|
} |
|
|
|
|
|
|
|
// Draw a color-filled circle (Vector version) |
|
|
|
// NOTE: On OpenGL 3.3 and ES2 we use QUADS to avoid drawing order issues (view rlglDraw) |
|
|
|
void DrawCircleV(Vector2 center, float radius, Color color) |
|
|
|
{ |
|
|
|
DrawCircleSector(center, radius, 0, 360, color); |
|
|
|
} |
|
|
|
|
|
|
|
// Draw circle outline |
|
|
|
void DrawCircleLines(int centerX, int centerY, float radius, Color color) |
|
|
|
{ |
|
|
|