cworth at cworth.org
Sat Jul 14 10:53:24 PDT 2007
I'm glad you're trying out cairo, and I'm glad you came here when you
ran into some problems. Hopefully we can help you get things working
the way you want.
On Sat, 14 Jul 2007 12:10:04 +0200, "Jose Hevia" wrote:
> I just want to confirm if those are bugs:
> I want to clear a surface with cairo,so the screen displays a color
> background with transparency, so I do:
> cairo_set_source_rgba (new->cr, 0,1,1,0.1);
So far, so good. You've now set the source pattern to a uniform color,
(cyan at 10% opacity).
> cairo_set_source_surface (new->cr,new->surface, 0, 0);
Oops, now you just replaced the source pattern with a new source
pattern based on the contents of new->surface. So if new->surface is
the same surface that new->cr is targeting, you won't be able to get
many drawing operations to have any useful effect, (you'll be drawing
the same content on top of itself).
> cairo_set_operator (new->cr, CAIRO_OPERATOR_CLEAR);
Oops, again, now you just started using an operator that completely
ignores the source pattern. This operator sets the destination to 0 in
every channel. What you want instead is the SOURCE operator that
copies the source pattern to the destination, (entirely ignoring the
original destination contents---unlike the default OVER operator which
blends the source pattern over the destination).
And this part is correct.
So the complete and corrected sequence is:
/* Clear contents to cyan with 10% opacity */
cairo_set_source_rgba (new->cr, 0., 1., 1., 0.1);
cairo_set_operator (new->cr, CAIRO_OPERATOR_SOURCE);
> BUG: I can't change clearing color. Is always(0,0,0,0). Is this a
No bug. Cairo was just implementing CAIRO_OPERATOR_CLEAR that you
You might take a look here, which directly answers your original
As well as here which explains some of the general concepts such as
> ANOTHER BUG:Transparency seems a function of the screen luminosity
> ((R+G+B)/3), instead of alpha--->(255,255.255,0) is always opaque
> white, no matter what is behind the window.
> Black (0,0,0,255) is opaque through.
I don't understand your question here. Cairo definitely doesn't do any
luminosity calculations. Is it inter-window transparency that you're
having trouble getting to work? If so, you'll have to ensure that
you're using an ARGB Window visual so that it contain the alpha
Also, you'll need to ensure that there's a compositing manager doing
something useful with those alpha values. But as you say:
> System Info: Ubuntu FF with beryl, cairo 1.4.2
Beryl should be doing the compositing manager role just fine.
So hopefully that helps. Please let us know if you have any further
questions. And have fun with cairo!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20070714/be8aa1a6/attachment.pgp
More information about the cairo