summaryrefslogtreecommitdiffstats
path: root/src/cairo_test.c
blob: 9c3683a81bcdf4a84d1956bc8d0e6dcd8f09a086 (plain) (blame)
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
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <stdlib.h>

#include <cairo.h>

static double in2pts(double in)
{
	/* 72 pts per inch */
	return in * 72;
}

static double cm2in(double cm)
{
	/* 1in = 2.54 cm */
	return cm / 2.54;
}

static double cm2pts(double cm)
{
	return in2pts(cm2in(cm));
}

void cairo_test(void)
{
	cairo_surface_t *surface;
	cairo_t *cr;
	
	surface = cairo_pdf_surface_create("test.pdf", cm2pts(10), cm2pts(10));
	cr = cairo_create(surface);
	cairo_set_source_rgb(cr, 1.0, 0.3, 0.7);
	cairo_rectangle(cr, cm2pts(0.25), cm2pts(0.25), cm2pts(0.5), cm2pts(0.5));
	cairo_fill(cr);
	cairo_destroy(cr);
	cairo_surface_destroy(surface);
}

int main (int argc, char** argv)
{
	cairo_test();
	return 0;
}