blob: 6d6bf54268311e8fb3ec35b765976e4303e9445c [file] [log] [blame]
#include "../api/pixel_formats.h"
#include "slides.h"
#include <cstdlib>
#include <cstring>
using namespace eskia;
#define SLIDE(name) \
static void name##_core(Frame* frame); \
static const char* name(Frame* frame) { \
if (frame) { name##_core(frame); } \
return #name; \
} \
static void name##_core(Frame* frame)
SLIDE(two_rects) {
Paint paint;
paint.color = rgba_8888(0.50f, 0.75f, 0.25f, 0.5f);
frame->draw(Rect{100,100,200,200}, paint, single_color, frame->srcover);
paint.color = rgba_8888(0.75f, 0.25f, 0.50f, 0.25f);
frame->draw(Rect{150,150,250,300}, paint, single_color, frame->srcover);
}
SLIDE(rand_rects) {
Paint paint;
for (int n = 1000; n --> 0; ) {
// Get some in-bounds coordinates.
float l = rand() % frame->width,
t = rand() % frame->height,
r = rand() % frame->width,
b = rand() % frame->height;
// Push them out a bit to make sure we clip.
l = l*1.50f - frame->width*0.25f;
t = t*1.50f - frame->height*0.25f;
r = r*1.50f - frame->width*0.25f;
b = b*1.50f - frame->height*0.25f;
int color = rand();
memcpy(&paint.color, &color, 4);
frame->draw(Rect{l,t,r,b}, paint, single_color, frame->srcover);
}
}
Slide* slides[] = {
two_rects,
rand_rects,
nullptr,
};