Draw circle performance update. Removed drawFilledCircle (unused).

This commit is contained in:
Steve 2016-03-03 07:47:03 +00:00
parent 11d5ed635f
commit d980e412f2
1 changed files with 10 additions and 29 deletions

View File

@ -92,20 +92,22 @@ void drawCircle(int cx, int cy, int radius, int r, int g, int b, int a)
int x = radius; int x = radius;
int y = 0; int y = 0;
int radiusError = 1 - x; int radiusError = 1 - x;
SDL_Point p[8];
SDL_SetRenderDrawColor(app.renderer, r, g, b, a); SDL_SetRenderDrawColor(app.renderer, r, g, b, a);
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND); SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
while (x >= y) while (x >= y)
{ {
SDL_RenderDrawPoint(app.renderer, x + cx, y + cy); p[0].x = x + cx; p[0].y = y + cy;
SDL_RenderDrawPoint(app.renderer, y + cx, x + cy); p[1].x = y + cx; p[1].y = x + cy;
SDL_RenderDrawPoint(app.renderer,-x + cx, y + cy); p[2].x = -x + cx; p[2].y = y + cy;
SDL_RenderDrawPoint(app.renderer,-y + cx, x + cy); p[3].x = -y + cx; p[3].y = x + cy;
SDL_RenderDrawPoint(app.renderer,-x + cx, -y + cy); p[4].x = -x + cx; p[4].y = -y + cy;
SDL_RenderDrawPoint(app.renderer,-y + cx, -x + cy); p[5].x = -y + cx; p[5].y = -x + cy;
SDL_RenderDrawPoint(app.renderer, x + cx, -y + cy); p[6].x = x + cx; p[6].y = -y + cy;
SDL_RenderDrawPoint(app.renderer, y + cx, -x + cy); p[7].x = y + cx; p[7].y = -x + cy;
SDL_RenderDrawPoints(app.renderer, p, 8);
y++; y++;
@ -123,27 +125,6 @@ void drawCircle(int cx, int cy, int radius, int r, int g, int b, int a)
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE); SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
} }
void drawFilledCircle(int cx, int cy, int radius, int r, int g, int b, int a)
{
int x, y;
SDL_SetRenderDrawColor(app.renderer, r, g, b, a);
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
for (y = -radius ; y <= radius ; y++)
{
for (x =- radius; x <= radius ; x++)
{
if (x * x + y * y <= radius * radius)
{
SDL_RenderDrawPoint(app.renderer, cx + x, cy + y);
}
}
}
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
}
void saveScreenshot(void) void saveScreenshot(void)
{ {
static int i = 0; static int i = 0;