Hello K.,
According to the new color builtin functions (%darken, %lighten, %is_dark, %is_light) [on V1.2021.6], we can now use on user color functions...
And for example replace '#automatic' by a tone_on_tone_color user function, as:
@startuml
!unquoted function $tone_on_tone_color($color)
!if %is_dark($color)
!$value = %lighten($color, 80)
!else
!$value = %darken($color, 80)
!endif
!return $value
!endfunction
legend
|<#white><color:#automatic> white area |
|<#red><color:#automatic> red area |
|<#blue><color:#automatic> blue area |
|<$tone_on_tone_color(#blue)><color:#blue> blue text |
|<$tone_on_tone_color(#white)><color:#white> white text |
|<$tone_on_tone_color(#red)><color:#red> red text |
endlegend
@enduml
And you can observe an expected result
Awaiting another builtin function for reverse, complementary or opposite color... (I can ask on a next wanted feature... )
If that can help,
Regards,
Th.