#include <stdlib.h>
#include <helianthus.h>
#include "drawing.h"
static double t = 0;
static int w = 0, h = 0;
static Framebuffer buffer;
static Animation texture;
void framebufferInit() {
buffer = createFramebufferFromFile("data/sprite/snake.png");
w = framebufferGetWidth(buffer);
h = framebufferGetHeight(buffer);
texture = createAnimationFromFramebuffer(buffer);
}
void framebufferDraw() {
double step = 0.1;
t += windowGetFrameTime();
while(t > step) {
saveState();
target(buffer);
strokeWidth(randomFloat()*64);
stroke(colorByHSVA(randomFloat()*360, 1, 1, randomFloat()));
point( randomFloat()*w, randomFloat()*h );
restoreState();
t -= step;
}
saveState();
translate(1024 - 256, 256);
rotate(30);
fill(colorByName("white"));
stroke(colorByName("blue"));
strokeWidth(2);
rectTextured(texture, -0.5*w, -0.5*h, w, h);
restoreState();
}