12
12
13
13
!global $LEGEND_FONT_COLOR = "#FFFFFF "
14
14
!global $LEGEND_TITLE_COLOR = "#000000 "
15
- !global $LEGEND_UNDEFINED_BG_COLOR = "#D5CFEE "
16
- !global $LEGEND_UNDEFINED_FONT_COLOR = "#8B77E4 "
15
+ ' %darken(darkkhaki,50), #khaki
16
+ !global $LEGEND_DARK_COLOR = "#66622E "
17
+ !global $LEGEND_LIGHT_COLOR = "#khaki "
17
18
18
19
' Labels
19
20
' ##################################
@@ -202,7 +203,7 @@ $tagSkin
202
203
!endprocedure
203
204
204
205
' arrow colors cannot start with # (legend background has to start with #)
205
- !function ColorNoHash ($c )
206
+ !function $ colorWithoutHash ($c )
206
207
!if (%substr ($c , 0 , 1 ) == "#")
207
208
!$c = %substr ($c ,1 )
208
209
!endif
@@ -213,39 +214,95 @@ $tagSkin
213
214
!$elementSkin = "skinparam arrow <<" + $tagStereo + ">> {" + %newline ()
214
215
!$elementSkin = $elementSkin + " Color "
215
216
!if ($lineColor != "")
216
- !$elementSkin = $elementSkin + ColorNoHash ($lineColor )
217
+ !$elementSkin = $elementSkin + $ colorWithoutHash ($lineColor )
217
218
!endif
218
219
!if ($textColor != "")
219
- !$elementSkin = $elementSkin + ";text :" + ColorNoHash ($textColor)
220
+ !$elementSkin = $elementSkin + ";text :" + $colorWithoutHash ($textColor)
220
221
!endif
221
222
!$elementSkin = $elementSkin + %newline ()
222
223
!$elementSkin = $elementSkin + "}" + %newline ()
223
224
$elementSkin
224
225
!endprocedure
225
226
226
- !function $tagLegendEntry ($tagStereo , $bgColor , $fontColor , $borderColor , $shadowing , $shape )
227
- !$tagEntry = "|"
228
- !if ($bgColor != "")
229
- !$bg = $bgColor
227
+ ' %is_dark() requires PlantUML version >=1.2021.6
228
+ !if (%function_exists ("%is_dark" ))
229
+ !$PlantUMLSupportsDynamicLegendColor = %true ()
230
+ !else
231
+ !$PlantUMLSupportsDynamicLegendColor = %false ()
232
+ !log "dynamic undefined legend colors" requires PlantUML version >= 1 . 2021 . 6 , therefore only static assigned colors are used
233
+ !endif
234
+
235
+ !unquoted function $contrastLegend ($color )
236
+ !if (%is_dark ($color ))
237
+ !$value = $LEGEND_LIGHT_COLOR
230
238
!else
231
- !$bg = $LEGEND_UNDEFINED_BG_COLOR
239
+ !$value = $LEGEND_DARK_COLOR
232
240
!endif
233
- ' named colors have to start with # too
234
- !if (%substr ($bg , 0 , 1 ) != "#")
235
- !$bg = "#" + $bg
236
- !endif
237
- !$tagEntry = $tagEntry + "<" + $bg +">"
238
- ' <U+25AF> ..white rectangle
239
- !if ($borderColor != "")
240
- !$tagEntry = $tagEntry + "<color :"+$borderColor+"> <U+25AF></color> "
241
+ !return $value
242
+ !endfunction
243
+
244
+ !unquoted function $flatLegend ($color )
245
+ !if (%is_dark ($color ))
246
+ !$value = $LEGEND_DARK_COLOR
241
247
!else
242
- !$tagEntry = $tagEntry + "< color :"+$bg+"> <U+25AF></color> "
248
+ !$value = $LEGEND_LIGHT_COLOR
243
249
!endif
244
- !if ($fontColor != "")
245
- !$tagEntry = $tagEntry + "<color :"+$fontColor+">"
250
+ !return $value
251
+ !endfunction
252
+
253
+ ' legend background has to start with #
254
+ !function $colorWithHash ($c )
255
+ !if (%substr ($c , 0 , 1 ) != "#")
256
+ !$c = "#" + $c
257
+ !endif
258
+ !return $c
259
+ !endfunction
260
+
261
+ !function $tagLegendEntry ($tagStereo , $bgColor , $fontColor , $borderColor , $shadowing , $shape )
262
+ !$bg = $bgColor
263
+ !$fo = $fontColor
264
+ !$bo = $borderColor
265
+
266
+ !if ($fo == "")
267
+ !if ($bg != "")
268
+ !if ($PlantUMLSupportsDynamicLegendColor )
269
+ !$fo = $contrastLegend ($bg )
270
+ !else
271
+ !$fo = $LEGEND_DARK_COLOR
272
+ !endif
273
+ !else
274
+ !if ($bo == "")
275
+ !$fo = $LEGEND_DARK_COLOR
276
+ !$bg = $LEGEND_LIGHT_COLOR
277
+ !else
278
+ !if ($PlantUMLSupportsDynamicLegendColor )
279
+ !$fo = $flatLegend ($bo )
280
+ !$bg = $contrastLegend ($bo )
281
+ !else
282
+ !$fo = $LEGEND_DARK_COLOR
283
+ !$bg = $LEGEND_LIGHT_COLOR
284
+ !endif
285
+ !endif
286
+ !endif
246
287
!else
247
- !$tagEntry = $tagEntry + "<color :"+$LEGEND_UNDEFINED_FONT_COLOR+">"
288
+ !if ($bg == "")
289
+ !if ($PlantUMLSupportsDynamicLegendColor )
290
+ !$bg = $contrastLegend ($fo )
291
+ !else
292
+ !$bg = $LEGEND_LIGHT_COLOR
293
+ !endif
294
+ !endif
295
+ !endif
296
+
297
+ !if ($bo == "")
298
+ !$bo = $bg
248
299
!endif
300
+
301
+ !$tagEntry = "|"
302
+ !$tagEntry = $tagEntry + "<" + $colorWithHash ($bg ) +">"
303
+ ' <U+25AF> ..white rectangle
304
+ !$tagEntry = $tagEntry + "<color :"+$bo+"> <U+25AF></color> "
305
+ !$tagEntry = $tagEntry + "<color :"+$fo+">"
249
306
!$tagEntry = $tagEntry + " " + $tagStereo + " "
250
307
!if ($shadowing == "true ")
251
308
!$tagEntry = $tagEntry + $LEGEND_SHADOW_TEXT
@@ -275,18 +332,28 @@ $elementSkin
275
332
!endfunction
276
333
277
334
!function $tagRelLegendEntry ($tagStereo , $textColor , $lineColor )
278
- !$tagEntry = "|"
279
- ' <U+2500> ..white line
280
- !if ($lineColor != "")
281
- !$tagEntry = $tagEntry + "<color :"+$lineColor+"> <U+2500></color> "
282
- !else
283
- !$tagEntry = $tagEntry + " <U +2500 > "
335
+ !$tc = $textColor
336
+ !$lc = $lineColor
337
+
338
+ !if ($tc == "")
339
+ !if ($PlantUMLSupportsDynamicLegendColor )
340
+ !$tc = $flatLegend ($ARROW_COLOR )
341
+ !else
342
+ !$tc = $LEGEND_DARK_COLOR
343
+ !endif
284
344
!endif
285
- !if ($textColor != "")
286
- !$tagEntry = $tagEntry + "<color :"+$textColor+">"
287
- !else
288
- !$tagEntry = $tagEntry + "<color :"+$LEGEND_UNDEFINED_FONT_COLOR+">"
345
+ !if ($lc == "")
346
+ !if ($PlantUMLSupportsDynamicLegendColor )
347
+ !$lc = $flatLegend ($ARROW_COLOR )
348
+ !else
349
+ !$lc = $LEGEND_DARK_COLOR
350
+ !endif
289
351
!endif
352
+
353
+ !$tagEntry = "|"
354
+ ' <U+2500> ..white line
355
+ !$tagEntry = $tagEntry + "<color :"+$lc+"> <U+2500></color> "
356
+ !$tagEntry = $tagEntry + "<color :"+$tc+">"
290
357
!$tagEntry = $tagEntry + " " + $tagStereo + " "
291
358
!if ($textColor == "")
292
359
!$tagEntry = $tagEntry + $LEGEND_NO_FONT_TEXT
0 commit comments