#ifdef PDF #include #else #include #endif int main(int argc, char **argv) { #ifdef PDF cairo_surface_t *s = cairo_pdf_surface_create("out.pdf", 200, 200); #else cairo_surface_t *s = cairo_svg_surface_create("out.svg", 200, 200); #endif cairo_t *cr = cairo_create(s); cairo_surface_t *image = cairo_image_surface_create_from_png("rail.png"); cairo_pattern_t *pattern = cairo_pattern_create_for_surface(image); cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT); cairo_set_source(cr, pattern); cairo_set_line_width(cr, cairo_image_surface_get_height(image)); cairo_move_to(cr, 0, 100); cairo_line_to(cr, 200, 100); cairo_stroke(cr); cairo_destroy(cr); cairo_surface_destroy(s); return 0; }