~l3kn/quad

8183975df38e1cc1c07533800bdeeb36a0805026 — Leon Rische 5 months ago e1253ad
Add configurable colors
1 files changed, 11 insertions(+), 2 deletions(-)

M quad.c
M quad.c => quad.c +11 -2
@@ 20,11 20,15 @@
#define MENU_X PADDING
#define MENU_Y PADDING

#define COLOR_BLACK 0x000000
#define COLOR_WHITE 0xFFFFFF

SDL_Window* window = NULL;
SDL_Renderer* renderer = NULL;

Node selection;
Rule rules[4];
int colors[2] = { COLOR_BLACK, COLOR_WHITE };

int outline = 1;
int quit = 0;


@@ 151,12 155,17 @@ void drawMenu() {
  drawRule(MENU_X, 8 * MENU_SIZE + MENU_Y, 1);
  drawRule(MENU_X, 11 * MENU_SIZE + MENU_Y, 2);
  drawRule(MENU_X, 14 * MENU_SIZE + MENU_Y, 3);
void setColor(int color) {
  int r = color >> 16;
  int g = (color >> 8) & 255;
  int b = color & 255;
  SDL_SetRenderDrawColor(renderer, r, g, b, SDL_ALPHA_OPAQUE);
}

void draw() {
  SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
  setColor(colors[0]);
  SDL_RenderClear(renderer);
  SDL_SetRenderDrawColor(renderer, 255, 255, 255, SDL_ALPHA_OPAQUE);
  setColor(colors[1]);

  drawMenu();
  drawSquare(CANVAS_X, CANVAS_Y, SIZE, BLACK, 1);