3
#include <emscripten.h>
6
static const int COLOR_COUNT = 32;
8
static SDL_Surface *screen;
9
static SDL_Color pal[COLOR_COUNT +1];
11
void pallete(int red, int green, int blue) {
12
//initialize sdl palette
13
//with gradient colors
19
for (int i=1; i< 1 + COLOR_COUNT; i++) {
20
pal[i].r = (float) red / COLOR_COUNT * i;
21
pal[i].g = (float) green / COLOR_COUNT * i;
22
pal[i].b = (float) blue / COLOR_COUNT * i;
26
SDL_SetColors(screen, pal, 0, 1 + COLOR_COUNT);
29
int main(int argc, char** argv) {
30
SDL_Init(SDL_INIT_VIDEO);
31
screen = SDL_SetVideoMode(600, 450, 8, SDL_HWSURFACE | SDL_HWPALETTE);
34
SDL_LockSurface(screen);
35
SDL_UnlockSurface(screen);
38
SDL_LockSurface(screen);
39
int size = screen->h * screen->pitch;
40
char *color = screen->pixels;
41
int divider = size / COLOR_COUNT;
44
*color = 1 + (i / divider); //red
48
SDL_UnlockSurface(screen);
52
printf("%s\n", argv[1]);
53
if (strcmp(argv[1], "-r") == 0) {
54
printf("set [red]\n");
57
if (strcmp(argv[1], "-g") == 0) {
58
printf("set [green]\n");
61
if (strcmp(argv[1], "-b") == 0) {
62
printf("set [blue]\n");
68
SDL_LockSurface(screen);
69
SDL_UnlockSurface(screen);