color.c

Go to the documentation of this file.
00001 
00025 #include "color.h"
00026 #include "render.h"
00027 
00028 SDL_Color colorFmtInd[COLOR_MAX] = {
00029     { 184, 50, 50, 255 },    // COLOR_RED
00030     { 24, 26, 167, 255 },    // COLOR_BLUE
00031     { 0, 160, 0, 255 },      // COLOR_GREEN
00032     { 132, 0, 132, 255 },    // COLOR_PURPLE
00033     { 0, 0, 0, 255 },        // COLOR_BLACK
00034     { 255, 255, 255, 255 },  // COLOR_WHITE
00035     { 183, 194, 95, 255 },   // COLOR_REGBACK
00036     { 163, 57, 21, 255 },    // COLOR_PONGBACK
00037     { 183, 194, 95, 255 },   // COLOR_BACK
00038     { 128, 128, 128, 255 },  // COLOR_OBSTACLE
00039     { 255, 255, 255, 127 }   // COLOR_TEXT
00040 };
00041 
00042 Uint32 colorVals[COLOR_MAX];
00043 
00044 void SetupColorVals() {
00045     int loop;
00046     for (loop = 0; loop < COLOR_MAX; loop++) {
00047         colorVals[loop] = SDL_MapRGBA(dInfo.display->format,
00048         colorFmtInd[loop].r, colorFmtInd[loop].g, colorFmtInd[loop].b,
00049         colorFmtInd[loop].unused);
00050     }
00051 }
00052 
00053 Uint32 ColorBlend(SDL_Color c, SDL_Color d, int partsC, int partsD) {
00054     int r, g ,b, a;
00055     // blend all the parts together
00056     r = (partsC * c.r + partsD * d.r) / (partsC + partsD);
00057     g = (partsC * c.g + partsD * d.g) / (partsC + partsD);
00058     b = (partsC * c.b + partsD * d.b) / (partsC + partsD);
00059     a = (partsC * c.unused + partsD * d.unused) / (partsC + partsD);
00060     // find a close device specific color and return it
00061     return SDL_MapRGBA(dInfo.display->format, r, g, b, a);
00062 }
00063 

Generated on Mon May 28 04:41:38 2007 for Retro Tank Super Attack by  doxygen 1.5.2