else
{
#endif
- float redstep = (float(bottom.red)-float(top.red)) / float(screen->h);
- float greenstep = (float(bottom.green)-float(top.green)) / float(screen->h);
- float bluestep = (float(bottom.blue) - float(top.blue)) / float(screen->h);
-
- for(float y = 0; y < screen->h; y += 2)
- fillrect(0, (int)y, screen->w, 2,
- int(float(top.red) + redstep * y),
- int(float(top.green) + greenstep * y),
- int(float(top.blue) + bluestep * y), 255);
+ if(&top == &bottom)
+ {
+ fillrect(0, 0, screen->w, screen->h, top.red, top.green, top.blue);
+ }
+ else
+ {
+ float redstep = (float(bottom.red)-float(top.red)) / float(screen->h);
+ float greenstep = (float(bottom.green)-float(top.green)) / float(screen->h);
+ float bluestep = (float(bottom.blue) - float(top.blue)) / float(screen->h);
+
+ for(float y = 0; y < screen->h; y += 2)
+ fillrect(0, (int)y, screen->w, 2,
+ int(float(top.red) + redstep * y),
+ int(float(top.green) + greenstep * y),
+ int(float(top.blue) + bluestep * y), 255);
+ }
#ifndef NOOPENGL
}
#ifndef NOOPENGL
#include <SDL_opengl.h>
#endif
-
+#include <iostream>
class Color
{
public:
: red(o.red), green(o.green), blue(o.blue), alpha(o.alpha)
{ }
+ bool operator==(const Color& o)
+ { if(red == o.red && green == o.green &&
+ blue == o.blue && alpha == o.alpha)
+ return true;
+ return false; }
+
Uint8 red, green, blue, alpha;
};
if(sdl_surface == NULL)
st_abort("Cannot create surface for the gradient", "SURFACE");
- float redstep = (float(bottom.red)-float(top.red)) / float(h);
- float greenstep = (float(bottom.green)-float(top.green)) / float(h);
- float bluestep = (float(bottom.blue) - float(top.blue)) / float(h);
-
- SDL_Rect rect;
- rect.x = 0;
- rect.w = w;
- rect.h = 1;
- for(float y = 0; y < h; y++)
+ if(top == bottom)
{
- rect.y = (int)y;
- SDL_FillRect(sdl_surface, &rect, SDL_MapRGB(sdl_surface->format,
- int(float(top.red) + redstep * y),
- int(float(top.green) + greenstep * y),
- int(float(top.blue) + bluestep * y)));
+ SDL_FillRect(sdl_surface, NULL, SDL_MapRGB(sdl_surface->format,
+ top.red, top.green, top.blue));
+ }
+ else
+ {
+ float redstep = (float(bottom.red)-float(top.red)) / float(h);
+ float greenstep = (float(bottom.green)-float(top.green)) / float(h);
+ float bluestep = (float(bottom.blue) - float(top.blue)) / float(h);
+
+ SDL_Rect rect;
+ rect.x = 0;
+ rect.w = w;
+ rect.h = 1;
+ for(float y = 0; y < h; y++)
+ {
+ rect.y = (int)y;
+ SDL_FillRect(sdl_surface, &rect, SDL_MapRGB(sdl_surface->format,
+ int(float(top.red) + redstep * y),
+ int(float(top.green) + greenstep * y),
+ int(float(top.blue) + bluestep * y)));
+ }
}
return sdl_surface;