summaryrefslogtreecommitdiffstatsci
path: root/src/mask.cpp
blob: b1906ac569f2fa9d53e99ba41f26fe35632b4dc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include <stdlib.h>
#include <cairo.h>

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

int
main(int argc, char *argv[]) {
  int i;
  int loops = 128*1024;
  cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 800, 80);
  cairo_t *cr = cairo_create (surface);
  cairo_pattern_t *mask;

  cairo_set_source_rgb (cr, 0, 0.5, 0);
  cairo_paint (cr);

  srand(0xdeadbeef);
  mask = cairo_pattern_create_rgba (0, 0, 0, 0.5);

  while (loops--) {
    cairo_mask (cr, mask);
  }

  cairo_destroy (cr);
  cairo_surface_write_to_png (surface, "mask.png");
  cairo_surface_destroy (surface);
  cairo_pattern_destroy (mask);
  return 0;
}