From: ultrastar AT online DOT tietokone DOT fi (Niki Ruusunko) To: djgpp AT delorie DOT com Date: Fri, 21 Aug 1998 21:35:09 +0300 Subject: Star drawing function Message-ID: Organization: Tietokone Online MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Content-ID: Precedence: bulk This is a function I plan to use in creating a sun bitmap in a game I'm making. void DrawStar(int color, int size) { int i; int starSize = size - (size >> 2); int r = getr32(color); int g = getg32(color); int b = getb32(color); int *c = new int[size]; float nr = 0, ng = 0, nb = 0; float steps = 255 / (size - starSize); for(i = 0; i < size - starSize; i++) { if (r) nr = r + steps + steps * i; if (g) ng = g + steps + steps * i; if (b) nb = b + steps + steps * i; c[size - i] = makecol32((int)nr, (int)ng, (int)nb); } steps = 255 / (starSize >> 1); for(i = 0; i <= starSize; i++) { nr = r + steps + steps * i; if (nr > 255) nr = 255; ng = g + steps + steps * i; if (ng > 255) ng = 255; nb = b + steps + steps * i; if (nb > 255) nb = 255; c[starSize - i] = makecol32((int)nr, (int)ng, (int)nb); } for(i = size; i >= 0; i--) circlefill(dbuffer, 320, 240, i, c[i]); delete [] c; } It does nice suns, but it doesn't work if the all color components (R, G and B) are either 0 or 255. It ends up drawing a the light field around the star in a different color (and almost solid, not gradient) and aligns the actual star gradient too much inside, creating a band. Just compile that(uses allegro), it is hard to explain. How can I fix it.