On Tue, 4 Jun 2019 19:46:39 +0200, Mike Wey wrote:

On 04-06-2019 04:17, Alex X wrote:

I'm simply trying to draw some lines on in a Drawing Area but for some reason the lines always have some transparency even with Alpha set to 1(it seems about 50% ish).

I was using setLineWidth at 0.75 trying to get a "finer" line. I just set it to 1 and it seemed to reduce the transparency.. and if I set it to 2 then there is no transparency but is this because they are overlapping? I don't understand why the line with would modify the alpha in any way(except for > 1 which would be overlap).

...

Any ideas? It's as if there is some global setting that set's the alpha then everything else is with respect to it. If I draw the same line over itself it gets darker(which is a solution but then requires me drawing everything more than once and doesn't explain what is going on).

Cairo uses the OVER operator by default, which will blend the
background and what your drawing together. So for your case you will
want to change it to SOURCE.

cr.setOperator(CairoOperator.SOURCE);

More information about the operators: https://cairographics.org/operators/

Unfortunately it didn't work. Well, I have a drawing underneath that seems to get darker suggesting it is working for that but the lines I'm drawing on top did not change ;/

It looks like it is one of the blending modes but the above simply does not work, In fact, it produces some weird ghosting effects when the drawing area moves. If I use IN things are worse, nothing is drawn at first then everything is very glitchy.

It seems that with SOURCE, what happens is that the drawing area is not cleared and so moving it around will produce overlapping images that blend per frame... which doesn't make sense for SOURCE... but maybe it suggests I need to clear the drawing area per frame?

I might need to take a look at some cario drawing code because I might not be setting stuff up correctly.