[cairo] Filling using a surface is not working
Mukund Sivaraman
muks at banu.com
Fri Apr 10 03:13:57 PDT 2009
Hi all
Can anyone spot the error in the following code? It creates 'pcontext'
which is made to hold a tiling pattern, and then uses it to fill
'context' whose surface is a GtkDrawingArea. But 'pcontext' appears
nowhere on 'context' with the following code:
cairo_t *context;
cairo_surface_t *surface;
cairo_t *pcontext;
context = gdk_cairo_create (GDK_DRAWABLE (window));
surface = cairo_surface_create_similar
(cairo_get_group_target (context),
CAIRO_CONTENT_COLOR_ALPHA, 4, 4);
pcontext = cairo_create (surface);
cairo_surface_destroy (surface);
cairo_new_path (pcontext);
cairo_set_source_rgba (pcontext, 1.0, 0.0, 0.0, 0.8);
cairo_rectangle (pcontext, 1, 1, 2, 2);
cairo_fill (pcontext);
cairo_set_source_surface (context, cairo_get_target (pcontext),
0, 0);
cairo_destroy (pcontext);
cairo_move_to (context, 100.5, 100.5);
cairo_line_to (context, 100.5, 600.5);
cairo_line_to (context, 600.5, 600.5);
cairo_line_to (context, 600.5, 550.5);
cairo_line_to (context, 150.5, 550.5);
cairo_line_to (context, 150.5, 100.5);
cairo_line_to (context, 100.5, 100.5);
cairo_fill (context);
Mukund
More information about the cairo
mailing list