Transparent background colours on Alt/Else elements

0 votes
asked Nov 24, 2022 in Question / help by Roujo

I'm using boxes around participants to indicate boundaries, like so:

A sequence diagram with an alt/else block, but no background

I would also like to use background colors in the alt/else block, to accentuate which are the expected outcome and which are the error cases. However, if I do this without any transparency, I end up losing track of the box around the first two participants:

A sequence diagram with an alt/else block, with the block's background color obscuring the box around the first two participants.

Adding transparency makes the participant's box apparent again, but the else block's colour isn't the #cc00007f I've set it to:

A sequence diagram with an alt/else block, where the alt's background color is green as intended but the else's isn't the red it should be.

It looks like the colour of the alt block covers the whole box, and the else's background colour is added on top if the alt's. Here's what it looks like if I remove the else's background colour:

A sequence diagram with an alt/else block, with the else using the alt's background colour

With solid/non-transparent colours, that's not an issue as the else's colour is going to cover the alt's. However, with transparent ones, it leads to less-than-ideal mixes. ^^

My question:
- Is there a way to achieve my goal of using transparent colours on the alt/else blocks without them mixing together?

Thank you!

commented Nov 25, 2022 by The-Lu (63,920 points)

3 Answers

0 votes
answered Nov 25, 2022 by Todd Musheno (2,680 points)
Transparent means some of the background shows through.
So solid red 50% transparent on a white background should look pink not red (mixing equal parts red and white gives you pink).
The color you should see on a semi transparent area should be the result of this mixing, NOT the original color, otherwise it's not transparent.
I hope this helps.
Todd
commented Nov 25, 2022 by Roujo

So solid red 50% transparent on a white background should look pink not red (mixing equal parts red and white gives you pink).

I agree, and it's what I'm trying to achieve here. ^^

If I don't put a background colour on the alt block and set the else block to #cc00007f, I get exactly what you're saying - the first block in the image below. The issue is that I don't get pink, I get a mix of the else block's and the alt block's background. For a side-by-side example, if the alt block is set to a green like #00cc007f and the else block is still set to #cc00007f, I don't get the same "transparent red/pink" colour, it blends with the alt's green and turns orange/brown:

A sequence diagram with two alt/else blocks. The first one only has a background colour on the else part, which is light red/pink. The second one also has a green background on the alt part, and the else ends up being brown.

The colour used for both else blocks is the same, and yet it doesn't display as the same because it's blended with the alt block's colour. Here's the code used to generate the diagram. What I would like is for the else block to stay transparent red, like this mockup I edited in paint.net:

Hence my question, clarified:
- Is there a way to achieve my goal of using transparent colours on the alt/else blocks without the else block's colour mixing with the alt's?

Thanks again! =)

0 votes
answered Nov 25, 2022 by plantuml (294,960 points)
It's definitively a bug.

We're going to have a look at it.

Thanks:
commented Nov 25, 2022 by Roujo
Awesome, thank you! =)
0 votes
answered Nov 26, 2022 by plantuml (294,960 points)

We have fixed this issue with "teoz" rendering engine. Fixing it with legacy engine is too complex.

Someday, "teoz" will be the default engine but right now you have to use !pragma teoz true to enable it.

So you can now have this.

Hope this helps!

commented Nov 26, 2022 by Roujo
That's great! Thank you for the quick reply and fix, it's much appreciated.

Have a nice day!
Roujo
...