I'm new to Cairo, trying to create text with transparent color and stroke.
stroke color's transparency works but text fill color transparency transparency_value
doesn't work.
If i reduce transparency_value
, text color just gets darker(black) and increasing transparency_value
makes text color brighter (green in my case)
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 640, 480);
cairo_t* cairo = cairo_create(surface);
cairo_set_font_face(cairo, myfont_face);
cairo_set_font_size(cairo, 25);
cairo_text_extents_t extents;
cairo_text_extents(cairo, "Hello World", &extents);
cairo_move_to(cairo, 200, 200);
cairo_text_path(cairo, "Hello World");
double transparency_value = 0.5;
cairo_set_source_rgba(cairo, 0,1,0,transparency_value ); //transparency doesn't work
//cairo_fill(cairo); //this didn't make a difference
cairo_fill_preserve(cairo);
cairo_set_source_rgba(cairo, 0.56, 0.76, 0.96, 0.5); //transparency works
cairo_set_line_width(cairo, 1.5);
cairo_stroke(cairo);
cairo_move_to
, or else i wouldn't see output. to make code short i had skippedcairo_move_to
.I have updated code. am i doing any mistake in the order of function calls? and did you try changingtransparency_value
in your code? – Objectify