~l3kn/quad

796172f267f7ff120db849fbd390d8cc1ad89189 — Leon Rische 5 months ago 4ede712
Make rendering limit configurable
2 files changed, 18 insertions(+), 2 deletions(-)

M README.md
M quad.c
M README.md => README.md +2 -0
@@ 11,3 11,5 @@ Needs the `sdl2-dev` package, run with `make`.
- `o` toggle outlines
- `c` reset rules
- `i` invert colors
- `1` increase limit / decrease resolution
- `2` decrease limit / increase resolution

M quad.c => quad.c +16 -2
@@ 9,7 9,6 @@

#define PADDING 20
#define SIZE 1024
#define LIMIT 8
#define SCALE 2
#define MENU_SIZE 64
#define MENU_WIDTH 640


@@ 32,6 31,7 @@ int colors[2] = { COLOR_BLACK, COLOR_WHITE };

int outline = 1;
int quit = 0;
int limit = 1;

void drawSquare(int x, int y, int s, unsigned long long pattern, int outline) {
  if (outline) {


@@ 68,7 68,7 @@ void expandNode(int x, int y, int s, Node node) {

void expandRule(int x, int y, int s, Rule* rule) {
  int h = s / 2;
  if (s > LIMIT) {
  if (s > limit) {
    expandNode(x, y, h, rule->tl);
    expandNode(x + h, y, h, rule->tr);
    expandNode(x, y + h, h, rule->bl);


@@ 199,6 199,20 @@ void handleKey(SDL_Event* event) {
    draw();
    break;
  }
  case SDLK_1: {
    if (limit < SIZE / 2) {
      limit <<= 1;
      draw();
    }
    break;
  }
  case SDLK_2: {
    if (limit > 1) {
      limit >>= 1;
      draw();
    }
    break;
  }
  }
}