#149: LegendColor considers brightness

pull/150/head
KIRCHSTH 5 years ago
parent 841aef26f4
commit 41b3a20f09

@ -12,8 +12,9 @@
!global $LEGEND_FONT_COLOR = "#FFFFFF" !global $LEGEND_FONT_COLOR = "#FFFFFF"
!global $LEGEND_TITLE_COLOR = "#000000" !global $LEGEND_TITLE_COLOR = "#000000"
!global $LEGEND_UNDEFINED_BG_COLOR = "#D5CFEE" ' %darken(darkkhaki,50), #khaki
!global $LEGEND_UNDEFINED_FONT_COLOR = "#8B77E4" !global $LEGEND_DARK_COLOR = "#66622E"
!global $LEGEND_LIGHT_COLOR = "#khaki"
' Labels ' Labels
' ################################## ' ##################################
@ -202,7 +203,7 @@ $tagSkin
!endprocedure !endprocedure
' arrow colors cannot start with # (legend background has to start with #) ' arrow colors cannot start with # (legend background has to start with #)
!function ColorNoHash($c) !function $colorWithoutHash($c)
!if (%substr($c, 0, 1) == "#") !if (%substr($c, 0, 1) == "#")
!$c = %substr($c,1) !$c = %substr($c,1)
!endif !endif
@ -213,39 +214,74 @@ $tagSkin
!$elementSkin = "skinparam arrow<<" + $tagStereo + ">> {" + %newline() !$elementSkin = "skinparam arrow<<" + $tagStereo + ">> {" + %newline()
!$elementSkin = $elementSkin + " Color " !$elementSkin = $elementSkin + " Color "
!if ($lineColor!="") !if ($lineColor!="")
!$elementSkin = $elementSkin + ColorNoHash($lineColor) !$elementSkin = $elementSkin + $colorWithoutHash($lineColor)
!endif !endif
!if ($textColor!="") !if ($textColor!="")
!$elementSkin = $elementSkin + ";text:" + ColorNoHash($textColor) !$elementSkin = $elementSkin + ";text:" + $colorWithoutHash($textColor)
!endif !endif
!$elementSkin = $elementSkin + %newline() !$elementSkin = $elementSkin + %newline()
!$elementSkin = $elementSkin + "}" + %newline() !$elementSkin = $elementSkin + "}" + %newline()
$elementSkin $elementSkin
!endprocedure !endprocedure
!function $tagLegendEntry($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape) !unquoted function $contrastColor($color)
!$tagEntry = "|" !if (%is_dark($color))
!if ($bgColor!="") !$value = $LEGEND_LIGHT_COLOR
!$bg = $bgColor
!else !else
!$bg = $LEGEND_UNDEFINED_BG_COLOR !$value = $LEGEND_DARK_COLOR
!endif
' named colors have to start with # too
!if (%substr($bg, 0, 1) != "#")
!$bg = "#" + $bg
!endif !endif
!$tagEntry = $tagEntry + "<" + $bg +">" !return $value
' <U+25AF> ..white rectangle !endfunction
!if ($borderColor!="")
!$tagEntry = $tagEntry + "<color:"+$borderColor+"> <U+25AF></color> " !unquoted function $flatColor($color)
!if (%is_dark($color))
!$value = $LEGEND_DARK_COLOR
!else !else
!$tagEntry = $tagEntry + "<color:"+$bg+"> <U+25AF></color> " !$value = $LEGEND_LIGHT_COLOR
!endif !endif
!if ($fontColor!="") !return $value
!$tagEntry = $tagEntry + "<color:"+$fontColor+">" !endfunction
' legend background has to start with #
!function $colorWithHash($c)
!if (%substr($c, 0, 1) != "#")
!$c = "#" + $c
!endif
!return $c
!endfunction
!function $tagLegendEntry($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape)
!$bg = $bgColor
!$fo = $fontColor
!$bo = $borderColor
!if ($fo == "")
!if ($bg != "")
!$fo = $contrastColor($bg)
!else
!if ($bo == "")
!$fo = $LEGEND_DARK_COLOR
!$bg = $LEGEND_LIGHT_COLOR
!else
!$fo = $flatColor($bo)
!$bg = $contrastColor($bo)
!endif
!endif
!else !else
!$tagEntry = $tagEntry + "<color:"+$LEGEND_UNDEFINED_FONT_COLOR+">" !if ($bg == "")
!$bg = $contrastColor($fo)
!endif
!endif
!if ($bo == "")
!$bo = $bg
!endif !endif
!$tagEntry = "|"
!$tagEntry = $tagEntry + "<" + $colorWithHash($bg) +">"
' <U+25AF> ..white rectangle
!$tagEntry = $tagEntry + "<color:"+$bo+"> <U+25AF></color> "
!$tagEntry = $tagEntry + "<color:"+$fo+">"
!$tagEntry = $tagEntry + " " + $tagStereo + " " !$tagEntry = $tagEntry + " " + $tagStereo + " "
!if ($shadowing == "true") !if ($shadowing == "true")
!$tagEntry = $tagEntry + $LEGEND_SHADOW_TEXT !$tagEntry = $tagEntry + $LEGEND_SHADOW_TEXT

Loading…
Cancel
Save