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