From a60ad393e94e233e761260f34fe71e83b38eab1d Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Thu, 23 Jun 2011 00:09:34 -0400 Subject: [PATCH] DrawUtils circle now fills, but alpha is a problem, since we're blending 1800 rectangles on each other --- drawutils.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drawutils.cpp b/drawutils.cpp index fd3ce64..890fccd 100644 --- a/drawutils.cpp +++ b/drawutils.cpp @@ -96,17 +96,30 @@ void DrawUtils::draw_circle_filled(SDL_Surface* dest, Sint16 int_x, Sint16 int_y float r = static_cast (int_r); SDL_Rect pen; - pen.w = 2; - pen.h = 2; - float i; for (i=0; i < 6.28318531; i += 0.0034906585) { pen.x = static_cast (x + cos(i) * r); pen.y = static_cast (y + sin(i) * r); - // pen.w = static_cast (2 + cos(i) * r); - // pen.h = static_cast (2 + sin(i) * r); + int w = static_cast (x - pen.x); + int h = static_cast (y - pen.y); + + if (w == 0) pen.w = 1; + else if (w < 0) + { + pen.x = x; + pen.w = abs(w); + } + else pen.w = w; + + if (h == 0) pen.h = 1; + else if (h < 0) + { + pen.y = y; + pen.h = abs(h); + } + else pen.h = h; if (pen.x >= dest->clip_rect.x && pen.y >= dest->clip_rect.y && @@ -116,7 +129,7 @@ void DrawUtils::draw_circle_filled(SDL_Surface* dest, Sint16 int_x, Sint16 int_y SDL_MapRGBA(dest->format, (colour >> 16) & 0xff, (colour >> 8) & 0xff, - colour & 0xff, alpha)); + colour & 0xff, 1)); } }