// - - - - - - - - - - - - - - - - - - - - - - - - - - // File: mypalette.cpp | // Purpose: implements palette modification functions | // Author: Taivo Lints, Estonia | // Date: March, 2003 | // Copyright: see copyright.txt | // - - - - - - - - - - - - - - - - - - - - - - - - - - #include "mypalette.h" #include "allegro.h" using namespace std; // - Function: make_grayscale_palette_64 - - // Changes colors start..start + 63 to a gradient (from black // to white), others remain the same. void make_grayscale_palette_64(int start) { RGB rgb; for(int i = start; i < start + 64; i++) { if(i > 255) break; rgb.r = rgb.g = rgb.b = i - start; set_color(i, &rgb); } } // - Function: make_blueish_palette_64 - - // Changes colors start..start + 63 to a gradient (from black // to some kind of blue-green), others remain the same. void make_blueish_palette_64(int start) { RGB rgb; for(int i = start; i < start + 64; i++) { if(i > 255) break; rgb.r = 0; rgb.g = static_cast<int>(static_cast<float>(i - start) / 1.5); rgb.b = i - start; set_color(i, &rgb); } } // - Function: change_color - - // Changes the color of a palette entry (with index color_nr). void change_color(int color_nr, int r, int g, int b) { RGB rgb; rgb.r = r; rgb.g = g; rgb.b = b; set_color(color_nr, &rgb); }