Background cairomm

2

I have a drawing where I paint like this:

// ******** Drawing the background ********* \
// Setting the color for the background
cairo_set_source_rgba(cr, 1, 1, 1, 1);
// Setting a rectangle
cairo_rectangle (cr, 0, 0, 200, 200);
cairo_stroke_preserve(cr);
cairo_fill(cr);
cairo_save(cr);

When I paint again on the background in this way (example only):

//Painting the signal
cairo_set_source_rgb(cr, 0, 0, 1);
cairo_move_to(cr, 10, 10);
cairo_line_to(cr, 20, 20);
cairo_stroke(cr);

The color, in this case blue, is not blue rgb (0,0,1) due to the white background. My question is: if I want a white background but the color of the blue line rgb (0,0,1), how do I do it?

Thank you.

    
asked by David Moreno 15.11.2018 в 13:07
source

1 answer

0

The color of the line you would paint would be blue rgb, because you paint overwriting the white box, just like when you paint in an image editing program paint on a white background: the last color It's the one that counts.

In your case, as you have not put transparencies, both the background box rgba:= (1, 1, 1, 1) and the line to paint rgb:= (1, 1, 1) <-> rgba:= (1, 1, 1, 1) crush the original value that there was. If you had used a rgb color with a transparency value other than 1 , you could get a value that is not the maximum intensity blue, but a linear interpolation between the background value and the current one .

For more information, you will have to look in the English biography for Alpha Blending

    
answered by 15.11.2018 в 13:14