/* Build with gcc -lm -lz -O2 -Wall `pkg-config --libs --cflags cairo` -o broadway broadway.c demo.c */ #include "broadway.h" #include #include #include #include static void diff_surfaces (cairo_surface_t *surface, cairo_surface_t *old_surface) { uint8_t *data, *old_data; uint32_t *line, *old_line; int w, h, stride, old_stride; int x, y; data = cairo_image_surface_get_data (surface); old_data = cairo_image_surface_get_data (old_surface); w = cairo_image_surface_get_width (surface); h = cairo_image_surface_get_height (surface); stride = cairo_image_surface_get_stride (surface); old_stride = cairo_image_surface_get_stride (old_surface); for (y = 0; y < h; y++) { line = (uint32_t *)data; old_line = (uint32_t *)old_data; for (x = 0; x < w; x++) { if ((*line & 0xffffff) == (*old_line & 0xffffff)) *old_line = 0; else *old_line = *line | 0xff000000; line ++; old_line ++; } data += stride; old_data += old_stride; } } static void snippet(cairo_t *cr, int i) { if (1) { cairo_save(cr); cairo_rotate (cr, i * 0.002); /* a custom shape that could be wrapped in a function */ double x0 = 25.6, /* parameters like cairo_rectangle */ y0 = 25.6, rect_width = 204.8, rect_height = 204.8, radius = 102.4; /* and an approximate curvature radius */ double x1,y1; x1=x0+rect_width; y1=y0+rect_height; if (rect_width/2