How to use variables as colors?

0 votes
asked Feb 27, 2022 in Question / help by Andy (160 points)

Dear PlantUML community,

could you help me out with using the variable !$MY_COLOR instead of #FF00FF for participant B

Thanks in advance,

Andy

@startuml
!$MY_COLOR = "#FF00FF"
participant A
participant B#FF00FF
'participant C$MY_COLOR
A -> B : Method()
A -> C: Method()
@enduml

1 Answer

0 votes
answered Feb 27, 2022 by Martin (8,360 points)
selected Feb 28, 2022 by Andy
 
Best answer

It is fine to use a space between the participant name and the colour, like this:

participant C $MY_COLOR

But to get it working without the space, you need the ## operator:

participant C##$MY_COLOR
commented Feb 28, 2022 by Andy (160 points)

Hello Martin,

thanks much:

1. stupid space frown . Nevertheless it is a bit strange for my why no space is needed with #FF00FF.

2. Link to the page https://plantuml.com/de/preprocessing is very helpful ( #pragma in c-language equals ! in PlantUML smiley)

Cheers Andy

commented Feb 28, 2022 by Martin (8,360 points)
edited Feb 28, 2022 by Martin
Plantuml doesn't use a formal grammar for its syntax, so there are a few quirks around what works and what doesn't.
...