Blob Blame Raw

#include <math.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <helianthus.h>


#include "arg.inc.c"
#include "img.inc.c"
#include "img.ldr.inc.c"
#include "filter.base.inc.c"
#include "filter.matrix.inc.c"
#include "filter.blend.inc.c"
#include "filter.curve.inc.c"
#include "filter.noise.inc.c"
#include "filter.blur.inc.c"
#include "filter.wind.inc.c"
#include "filter.icy.inc.c"



Animation anim;
char *argvv[] = {"-i", "data/input/text.png", "-o", "data/output/icy-text.png", "-s", "4" };
char **argv;
int argc;


void generate() {
  if (anim) {
    animationDestroy(anim);
    anim = NULL;
  }
  Img img = {};
  if (icyGenerate(&img, argc, argv)) {
    unsigned char *data = imgToInt(&img);
    anim = createAnimationFromImage(img.w, img.h, data, FALSE);
    free(data);
    if (img.w < 512) {
      windowSetWidth(img.w);
      windowSetHeight(img.h);
    }
    imgDestroy(&img);
  }
}


void init() {
  background(COLOR_BLACK);
  generate();
}


void draw() {
  if (keyWentDown("space")) generate();
  noStroke();
  rectTextured(anim, 0, 0, windowGetWidth(), windowGetHeight());
}


int main(int largc, char **largv) {
  if (largc > 1) {
    argc = largc - 1;
    argv = largv + 1;
  } else {
    argc = sizeof(argvv)/sizeof(*argvv);
    argv = argvv;
  }
  windowSetInit(&init);
  windowSetDraw(&draw);
  windowRun();
  return 0;
}