#include #include #ifdef CAIRO_HAS_PS_SURFACE # include #endif int main(int a_argc, char *a_argv[]) { cairo_t *cr; int dx = 140, dy = 100; // width, height double l_xofs = 10, l_yofs = 10; // offset from edge cairo_surface_t *l_surface = cairo_ps_surface_create("test.ps", dx, dy); if (!l_surface) return -1; // Set up surface cairo_surface_set_fallback_resolution(l_surface, 300, 300); cairo_surface_set_device_offset(l_surface, l_xofs, l_yofs); cr = cairo_create(l_surface); // create cairo context dx -= 2*l_xofs; dy -= 2*l_yofs; // adjust width & height cairo_rectangle(cr, 0, 0, dx, dy); // Draw a rectangle cairo_set_source_rgba(cr, 1,.8,.2, .8); // set src colour : this fails // cairo_set_source_rgb(cr, 1,.8,.2); // set src colour : this works cairo_fill_preserve(cr); // fill, preserving path cairo_move_to(cr, 0, 0); // draw a cross between corners cairo_line_to(cr, dx, dy); cairo_move_to(cr, dx, 0); cairo_line_to(cr, 0, dy); cairo_set_source_rgb(cr, 0,0,0); // set colour black cairo_stroke(cr); // draw the cross cairo_move_to(cr, dx/2, dy/2); // go to center of cross cairo_show_text(cr, "Testing"); // show some text cairo_show_page(cr); // output page cairo_surface_finish(l_surface); // complete the postscript cairo_destroy(cr); // and clean up cairo_surface_destroy(l_surface); return 0; }