// gcc `pkg-config --cflags --libs cairo` cairo-test.c -o cairo-test #include #include #include #define WIDTH 400 #define HEIGHT 400 int main (void) { cairo_t *cr; cairo_surface_t *surface; surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT); cr = cairo_create (surface); cairo_set_line_width (cr, 15); //cairo_translate (cr, 0.0, 1.0); // works OK cairo_translate (cr, 0.0, 1.5); // gives segmentation fault cairo_rectangle (cr, 0, 0, WIDTH, HEIGHT); cairo_clip (cr); cairo_push_group (cr); cairo_move_to (cr, 200, 100); cairo_line_to (cr, 300, 300); cairo_rel_line_to (cr, -200, 0); cairo_close_path (cr); cairo_pop_group (cr); cairo_stroke (cr); cairo_surface_write_to_png (surface, "test.png"); cairo_surface_destroy (surface); cairo_destroy (cr); return 0; }