Donc j'essaie de mettre en place un masque au Caire, mais je ne peux pas le faire changer les choses. Ci-dessous j'ai un programme simple basé sur celui ici: http://snipplr.com/view/22584/cairo-hello-world-examble/.Le masquage du Caire - y a-t-il quelque chose qui me manque?
Je mets un masque complètement transparent donc rien ne devrait être dessiné, mais cela ne semble pas avoir d'effet - le texte est toujours dessiné. Mon code est ci-dessous. Qu'est-ce que je rate?
Merci!
int main(int argc, char* argv[])
{
cairo_surface_t* surface;
cairo_t* cr;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 200, 40);
cr = cairo_create (surface);
//****
// Here I create a pattern with an alpha of zero and set it to be cairo's mask
// According to http://www.cairographics.org/manual/cairo-context.html#cairo-mask
// "Opaque areas of pattern are painted with the source, transparent areas are not painted."
// Shouldn't this make it so nothing gets drawn?
//****
cairo_pattern_t* nothing = cairo_pattern_create_rgba(0,0,0,0);
cairo_mask (cr, nothing);
cairo_text_extents_t te;
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_select_font_face (cr, "Georgia",
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 20.0);
cairo_text_extents (cr, "hello cairo!", &te);
cairo_move_to (cr, 20, 20);
cairo_show_text (cr, "hello cairo!");
cairo_fill(cr);
// An image gets drawn that says "hello cairo!" in big letters
cairo_surface_write_to_png(surface, "hello_cairo.png");
return 0;
}
Je sais que beaucoup de temps s'est écoulé, mais est-ce que cairo_mask est identique à opacityMask dans xps? – Michele