Extend existing sprites for use in deployment diagram.

0 votes
asked Apr 17 in Question / help by anonymous
Hi, I want to extend an existing sprite for reuse throughout my diagram, something like this:

@startuml
!include <tupadr3/common>
!include <office/Concepts/firewall>
sprite myFW {
OFF_FIREWALL_ORANGE
scale=0.5
color=red
}

node "<$myFW> label"
node "<$myFW> label2"
@enduml

Does this feature already exist? What would be best way be to implement this, if so?

1 Answer

0 votes
answered Apr 17 by plantuml (226,400 points)

One possible option is to use the preprocessor for this :

@startuml
!include <tupadr3/common>
!include <office/Concepts/firewall>

!function $orange_firewall() !return "<$firewall,scale=.4,color=orange>"

node "$orange_firewall() label1" as node1
node "$orange_firewall() label2" as node2
@enduml

Another option :

@startuml
!include <tupadr3/common>
!include <office/Concepts/firewall>

!$orange_firewall = "<$firewall,scale=.4,color=orange>"

node "$orange_firewall label1" as node1
node "$orange_firewall label2" as node2
@enduml

or :

@startuml
!include <tupadr3/common>
!include <office/Concepts/firewall>

!unquoted function $firewall($col) !return "<$firewall,scale=.4,color=" + $col + ">"

node "$firewall(red) label1" as node1
node "$firewall(blue) label2" as node2
@enduml

Does it help ?

commented Apr 18 by anonymous
Works perfectly! Thank you!
...