Skip to content

Commit ce5a3ea

Browse files
authored
Merge pull request #173 from kirchsth/feature/defaultSprite
Tags support sprites (incl. img support), technology and custom legend text
2 parents 990010f + a05be2c commit ce5a3ea

File tree

11 files changed

+681
-141
lines changed

11 files changed

+681
-141
lines changed

C4.puml

Lines changed: 230 additions & 95 deletions
Large diffs are not rendered by default.

C4_Component.puml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
UpdateElementStyle("component", $COMPONENT_BG_COLOR, $COMPONENT_FONT_COLOR, $COMPONENT_BORDER_COLOR)
2727
UpdateElementStyle("external_component", $EXTERNAL_COMPONENT_BG_COLOR, $COMPONENT_FONT_COLOR, $EXTERNAL_COMPONENT_BORDER_COLOR)
2828

29+
' shortcuts with default colors
30+
!unquoted procedure AddComponentTag($tagStereo, $bgColor=$COMPONENT_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$COMPONENT_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="")
31+
AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite)
32+
!endprocedure
33+
!unquoted procedure AddExternalComponentTag($tagStereo, $bgColor=$EXTERNAL_COMPONENT_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$EXTERNAL_COMPONENT_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="")
34+
AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite)
35+
!endprocedure
36+
2937
' Layout
3038
' ##################################
3139

@@ -54,36 +62,48 @@ endlegend
5462
!return '=='+$label+'\n//<size:'+$TECHN_FONT_SIZE+'>['+$techn+']</size>//'
5563
!endif
5664
!if ($descr == "") && ($sprite != "")
57-
!return '<$'+$sprite+'>\n=='+$label+'\n//<size:'+$TECHN_FONT_SIZE+'>['+$techn+']</size>//'
65+
!return $getSprite($sprite)+'\n=='+$label+'\n//<size:'+$TECHN_FONT_SIZE+'>['+$techn+']</size>//'
5866
!endif
5967
!if ($descr != "") && ($sprite == "")
6068
!return '=='+$label+'\n//<size:'+$TECHN_FONT_SIZE+'>['+$techn+']</size>//\n\n '+$descr
6169
!endif
6270
!if ($descr != "") && ($sprite != "")
63-
!return '<$'+$sprite+'>\n=='+$label+'\n//<size:'+$TECHN_FONT_SIZE+'>['+$techn+']</size>//\n\n '+$descr
71+
!return $getSprite($sprite)+'\n=='+$label+'\n//<size:'+$TECHN_FONT_SIZE+'>['+$techn+']</size>//\n\n '+$descr
6472
!endif
6573
!endfunction
6674

67-
!unquoted procedure Component($alias, $label, $techn, $descr="", $sprite="", $tags="", $link="")
75+
!unquoted procedure Component($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
76+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "component")
77+
!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "component")
6878
rectangle "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("component",$tags) as $alias $getLink($link)
6979
!endprocedure
7080

71-
!unquoted procedure ComponentDb($alias, $label, $techn, $descr="", $sprite="", $tags="", $link="")
81+
!unquoted procedure ComponentDb($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
82+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "component")
83+
!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "component")
7284
database "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("component",$tags) as $alias $getLink($link)
7385
!endprocedure
7486

75-
!unquoted procedure ComponentQueue($alias, $label, $techn, $descr="", $sprite="", $tags="", $link="")
87+
!unquoted procedure ComponentQueue($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
88+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "component")
89+
!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "component")
7690
queue "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("component",$tags) as $alias $getLink($link)
7791
!endprocedure
7892

79-
!unquoted procedure Component_Ext($alias, $label, $techn, $descr="", $sprite="", $tags="", $link="")
93+
!unquoted procedure Component_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
94+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_component")
95+
!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_component")
8096
rectangle "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_component",$tags) as $alias $getLink($link)
8197
!endprocedure
8298

83-
!unquoted procedure ComponentDb_Ext($alias, $label, $techn, $descr="", $sprite="", $tags="", $link="")
99+
!unquoted procedure ComponentDb_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
100+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_component")
101+
!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_component")
84102
database "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_component",$tags) as $alias $getLink($link)
85103
!endprocedure
86104

87-
!unquoted procedure ComponentQueue_Ext($alias, $label, $techn, $descr="", $sprite="", $tags="", $link="")
105+
!unquoted procedure ComponentQueue_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
106+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_component")
107+
!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_component")
88108
queue "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_component",$tags) as $alias $getLink($link)
89109
!endprocedure

C4_Container.puml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
UpdateElementStyle("container", $CONTAINER_BG_COLOR, $ELEMENT_FONT_COLOR, $CONTAINER_BORDER_COLOR)
2424
UpdateElementStyle("external_container", $EXTERNAL_CONTAINER_BG_COLOR, $ELEMENT_FONT_COLOR, $EXTERNAL_CONTAINER_BORDER_COLOR)
2525

26+
' shortcuts with default colors
27+
!unquoted procedure AddContainerTag($tagStereo, $bgColor=$CONTAINER_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$CONTAINER_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="")
28+
AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite)
29+
!endprocedure
30+
!unquoted procedure AddExternalContainerTag($tagStereo, $bgColor=$EXTERNAL_CONTAINER_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$EXTERNAL_CONTAINER_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="")
31+
AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite)
32+
!endprocedure
33+
2634
' Layout
2735
' ##################################
2836

@@ -49,37 +57,49 @@ endlegend
4957
!return '=='+$label+'\n//<size:'+$TECHN_FONT_SIZE+'>['+$techn+']</size>//'
5058
!endif
5159
!if ($descr == "") && ($sprite != "")
52-
!return '<$'+$sprite+'>\n=='+$label+'\n//<size:'+$TECHN_FONT_SIZE+'>['+$techn+']</size>//'
60+
!return $getSprite($sprite)+'\n=='+$label+'\n//<size:'+$TECHN_FONT_SIZE+'>['+$techn+']</size>//'
5361
!endif
5462
!if ($descr != "") && ($sprite == "")
5563
!return '=='+$label+'\n//<size:'+$TECHN_FONT_SIZE+'>['+$techn+']</size>//\n\n '+$descr
5664
!endif
5765
!if ($descr != "") && ($sprite != "")
58-
!return '<$'+$sprite+'>\n=='+$label+'\n//<size:'+$TECHN_FONT_SIZE+'>['+$techn+']</size>//\n\n '+$descr
66+
!return $getSprite($sprite)+'\n=='+$label+'\n//<size:'+$TECHN_FONT_SIZE+'>['+$techn+']</size>//\n\n '+$descr
5967
!endif
6068
!endfunction
6169

62-
!unquoted procedure Container($alias, $label, $techn, $descr="", $sprite="", $tags="", $link="")
70+
!unquoted procedure Container($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
71+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "container")
72+
!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "container")
6373
rectangle "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("container", $tags) as $alias $getLink($link)
6474
!endprocedure
6575

66-
!unquoted procedure ContainerDb($alias, $label, $techn, $descr="", $sprite="", $tags="", $link="")
76+
!unquoted procedure ContainerDb($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
77+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "container")
78+
!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "container")
6779
database "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("container", $tags) as $alias $getLink($link)
6880
!endprocedure
6981

70-
!unquoted procedure ContainerQueue($alias, $label, $techn, $descr="", $sprite="", $tags="", $link="")
82+
!unquoted procedure ContainerQueue($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
83+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "container")
84+
!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "container")
7185
queue "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("container", $tags) as $alias $getLink($link)
7286
!endprocedure
7387

74-
!unquoted procedure Container_Ext($alias, $label, $techn, $descr="", $sprite="", $tags="", $link="")
88+
!unquoted procedure Container_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
89+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_container")
90+
!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_container")
7591
rectangle "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_container", $tags) as $alias $getLink($link)
7692
!endprocedure
7793

78-
!unquoted procedure ContainerDb_Ext($alias, $label, $techn, $descr="", $sprite="", $tags="", $link="")
94+
!unquoted procedure ContainerDb_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
95+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_container")
96+
!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_container")
7997
database "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_container", $tags) as $alias $getLink($link)
8098
!endprocedure
8199

82-
!unquoted procedure ContainerQueue_Ext($alias, $label, $techn, $descr="", $sprite="", $tags="", $link="")
100+
!unquoted procedure ContainerQueue_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
101+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_container")
102+
!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_container")
83103
queue "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_container", $tags) as $alias $getLink($link)
84104
!endprocedure
85105

C4_Context.puml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ UpdateElementStyle("external_person", $EXTERNAL_PERSON_BG_COLOR, $ELEMENT_FONT_C
3030
UpdateElementStyle("system", $SYSTEM_BG_COLOR, $ELEMENT_FONT_COLOR, $SYSTEM_BORDER_COLOR)
3131
UpdateElementStyle("external_system", $EXTERNAL_SYSTEM_BG_COLOR, $ELEMENT_FONT_COLOR, $EXTERNAL_SYSTEM_BORDER_COLOR)
3232

33+
' shortcuts with default colors
34+
!unquoted procedure AddPersonTag($tagStereo, $bgColor=$PERSON_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$PERSON_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="")
35+
AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, "", $legendText, $legendSprite)
36+
!endprocedure
37+
!unquoted procedure AddExternalPersonTag($tagStereo, $bgColor=$EXTERNAL_PERSON_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$EXTERNAL_PERSON_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="")
38+
AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, "", $legendText, $legendSprite)
39+
!endprocedure
40+
!unquoted procedure AddSystemTag($tagStereo, $bgColor=$SYSTEM_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$SYSTEM_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="")
41+
AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, "", $legendText, $legendSprite)
42+
!endprocedure
43+
!unquoted procedure AddExternalSystemTag($tagStereo, $bgColor=$EXTERNAL_SYSTEM_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$EXTERNAL_SYSTEM_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="")
44+
AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, "", $legendText, $legendSprite)
45+
!endprocedure
3346

3447
' Sprites
3548
' ##################################
@@ -183,20 +196,20 @@ endlegend
183196
' ##################################
184197

185198
!function $getPerson($label, $descr, $sprite)
186-
!if ($sprite == "") && ($defaultPersonSprite!="")
199+
!if ($sprite == "") && ($defaultPersonSprite != "")
187200
!$sprite = $defaultPersonSprite
188201
!endif
189202
!if ($descr == "") && ($sprite == "")
190203
!return '=='+$label
191204
!endif
192205
!if ($descr == "") && ($sprite != "")
193-
!return '<$'+$sprite+'>\n=='+$label
206+
!return $getSprite($sprite)+'\n=='+$label
194207
!endif
195208
!if ($descr != "") && ($sprite == "")
196209
!return '=='+$label+'\n\n '+$descr
197210
!endif
198211
!if ($descr != "") && ($sprite != "")
199-
!return '<$'+$sprite+'>\n=='+$label+'\n\n '+$descr
212+
!return $getSprite($sprite)+'\n=='+$label+'\n\n '+$descr
200213
!endif
201214
!endfunction
202215

@@ -205,17 +218,18 @@ endlegend
205218
!return '=='+$label
206219
!endif
207220
!if ($descr == "") && ($sprite != "")
208-
!return '<$'+$sprite+'>\n=='+$label
221+
!return $getSprite($sprite)+'\n=='+$label
209222
!endif
210223
!if ($descr != "") && ($sprite == "")
211224
!return '=='+$label+'\n\n '+$descr
212225
!endif
213226
!if ($descr != "") && ($sprite != "")
214-
!return '<$'+$sprite+'>\n=='+$label+'\n\n '+$descr
227+
!return $getSprite($sprite)+'\n=='+$label+'\n\n '+$descr
215228
!endif
216229
!endfunction
217230

218231
!unquoted procedure Person($alias, $label, $descr="", $sprite="", $tags="", $link="")
232+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "person")
219233
!if ($portraitPerson == "portrait") && ($sprite == "")
220234
actor "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link)
221235
!elseif ($portraitPerson == "outline") && ($sprite == "")
@@ -226,6 +240,7 @@ rectangle "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("person",
226240
!endprocedure
227241

228242
!unquoted procedure Person_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="")
243+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_person")
229244
!if ($portraitPerson == "portrait") && ($sprite == "")
230245
actor "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link)
231246
!elseif ($portraitPerson == "outline") && ($sprite == "")
@@ -236,26 +251,32 @@ rectangle "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("external_
236251
!endprocedure
237252

238253
!unquoted procedure System($alias, $label, $descr="", $sprite="", $tags="", $link="")
254+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "system")
239255
rectangle "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("system", $tags) as $alias $getLink($link)
240256
!endprocedure
241257

242258
!unquoted procedure System_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="")
259+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_system")
243260
rectangle "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("external_system", $tags) as $alias $getLink($link)
244261
!endprocedure
245262

246263
!unquoted procedure SystemDb($alias, $label, $descr="", $sprite="", $tags="", $link="")
264+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "system")
247265
database "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("system", $tags) as $alias $getLink($link)
248266
!endprocedure
249267

250268
!unquoted procedure SystemQueue($alias, $label, $descr="", $sprite="", $tags="", $link="")
269+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "system")
251270
queue "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("system", $tags) as $alias $getLink($link)
252271
!endprocedure
253272

254273
!unquoted procedure SystemDb_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="")
274+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_system")
255275
database "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("external_system", $tags) as $alias $getLink($link)
256276
!endprocedure
257277

258278
!unquoted procedure SystemQueue_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="")
279+
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_system")
259280
queue "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("external_system", $tags) as $alias $getLink($link)
260281
!endprocedure
261282

0 commit comments

Comments
 (0)