-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Please add the Robot shape #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi! I assume with "Robot" you mean an automated system that represents the User? The reason for asking is that, looking at the C4 documentation, I can not find mention of the Robot shape. It is currently already possible to change the sprite for a user, using a parameter @startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/v2.4.0/C4_Container.puml
!include https://raw.githubusercontent.com/tupadr3/plantuml-icon-font-sprites/v2.4.0/font-awesome-5/robot.puml
LAYOUT_WITH_LEGEND()
Person(user, "Robot", "Non-human User", $sprite="robot")
Container(container, "Some Container", "Technology", "Optional Description", $sprite="robot")
System(system, "Some System", "Also non-human", $sprite="robot")
Rel(user, container, "Label", "Technology")
Rel(system, container, "Label", "Other Technology")
@enduml Would that suffice for your use-case? |
Yes, for example a user of an API, or automation.
Oh yes there it is: https://github.com./structurizr/dsl/blob/master/docs/language-reference.md#element-style
I actually did that, imported the sprite, etc. But it would be much simpler if I could just name the sprite "robot" in the same sense I can with "person" and "person2". |
Correct. A point many people miss is that C4 model does not prescribe any notation in terms of colours, shapes, etc. From https://c4model.com/#Notation
The robot shape you're referring to is from the Structurizr tooling, which is my implementation of a tool that supports the C4 model. It also implements many other shapes too, but these aren't a part of the C4 model. C4 model != Structurizr. |
@simonbrowndotje Thank you for chiming in! Adding other shapes was discussed in more detail in #145. As Simon mentioned, C4 model != Structurizr. There is also the problem that there is no "Robot" equivalent shape in PlantUML, so we would need to fall back to using sprites anyway (which is already possible). It would be possible to create a To give you an idea what such an implementation would look like: !global $ROBOT_SHAPE = "actor"
!global $ROBOT_BG_COLOR = "#0D559C"
!global $ROBOT_BORDER_COLOR = "#0D559C"
!global $EXTERNAL_ROBOT_BG_COLOR = "#7E7E7E"
!global $EXTERNAL_ROBOT_BORDER_COLOR = "#7E7E7E"
!global $defaultRobotSprite = "robot"
AddElementTag('robot', $bgColor=$ROBOT_BG_COLOR, $borderColor=$ROBOT_BORDER_COLOR, $sprite=$defaultRobotSprite)
AddElementTag('external_robot', $bgColor=$EXTERNAL_ROBOT_BG_COLOR, $borderColor=$EXTERNAL_ROBOT_BORDER_COLOR, $sprite=$defaultRobotSprite)
UpdateElementStyle("robot", $ROBOT_BG_COLOR, $ELEMENT_FONT_COLOR, $ROBOT_BORDER_COLOR)
UpdateElementStyle("external_robot", $EXTERNAL_ROBOT_BG_COLOR, $ELEMENT_FONT_COLOR, $EXTERNAL_ROBOT_BORDER_COLOR)
!unquoted procedure Robot($alias, $label, $descr="", $sprite="", $tags="", $link="")
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "robot")
rectangle "$getRobot($label, $descr, $sprite)$getProps()" $toStereos("robot", $tags) as $alias $getLink($link)
!endprocedure
!unquoted procedure Robot_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="")
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_robot")
rectangle "$getRobot($label, $descr, $sprite)$getProps()" $toStereos("external_robot", $tags) as $alias $getLink($link)
!endprocedure
!function $getRobot($label, $descr, $sprite)
!if ($sprite == "") && ($defaultRobotSprite != "")
!$sprite = $defaultRobotSprite
!endif
!if ($descr == "") && ($sprite == "")
!return '=='+$label
!endif
!if ($descr == "") && ($sprite != "")
!return $getSprite($sprite)+'\n=='+$label
!endif
!if ($descr != "") && ($sprite == "")
!return '=='+$label+'\n\n '+$descr
!endif
!if ($descr != "") && ($sprite != "")
!return $getSprite($sprite)+'\n=='+$label+'\n\n '+$descr
!endif
!endfunction
!procedure LAYOUT_WITH_LEGEND()
hide stereotype
legend right
|<color:$LEGEND_TITLE_COLOR>**Legend**</color> |
|<$PERSON_BG_COLOR> person |
|<$ROBOT_BG_COLOR> robot |
|<$SYSTEM_BG_COLOR> system |
|<$CONTAINER_BG_COLOR> container |
|<$COMPONENT_BG_COLOR> component |
|<$EXTERNAL_PERSON_BG_COLOR> external person |
|<$EXTERNAL_ROBOT_BG_COLOR> external robot |
|<$EXTERNAL_SYSTEM_BG_COLOR> external system |
|<$EXTERNAL_CONTAINER_BG_COLOR> external container |
|<$EXTERNAL_COMPONENT_BG_COLOR> external component |
endlegend
!endprocedure Full PlantUML Diagram@startuml
!include https://raw.githubusercontent.com/tupadr3/plantuml-icon-font-sprites/v2.4.0/font-awesome-5/robot.puml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/v2.4.0/C4_Container.puml
!global $ROBOT_SHAPE = "actor"
!global $ROBOT_BG_COLOR = "#0D559C"
!global $ROBOT_BORDER_COLOR = "#0D559C"
!global $EXTERNAL_ROBOT_BG_COLOR = "#7E7E7E"
!global $EXTERNAL_ROBOT_BORDER_COLOR = "#7E7E7E"
!global $defaultRobotSprite = "robot"
AddElementTag('robot', $bgColor=$ROBOT_BG_COLOR, $borderColor=$ROBOT_BORDER_COLOR, $sprite=$defaultRobotSprite)
AddElementTag('external_robot', $bgColor=$EXTERNAL_ROBOT_BG_COLOR, $borderColor=$EXTERNAL_ROBOT_BORDER_COLOR, $sprite=$defaultRobotSprite)
UpdateElementStyle("robot", $ROBOT_BG_COLOR, $ELEMENT_FONT_COLOR, $ROBOT_BORDER_COLOR)
UpdateElementStyle("external_robot", $EXTERNAL_ROBOT_BG_COLOR, $ELEMENT_FONT_COLOR, $EXTERNAL_ROBOT_BORDER_COLOR)
!unquoted procedure Robot($alias, $label, $descr="", $sprite="", $tags="", $link="")
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "robot")
rectangle "$getRobot($label, $descr, $sprite)$getProps()" $toStereos("robot", $tags) as $alias $getLink($link)
!endprocedure
!unquoted procedure Robot_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="")
!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_robot")
rectangle "$getRobot($label, $descr, $sprite)$getProps()" $toStereos("external_robot", $tags) as $alias $getLink($link)
!endprocedure
!function $getRobot($label, $descr, $sprite)
!if ($sprite == "") && ($defaultRobotSprite != "")
!$sprite = $defaultRobotSprite
!endif
!if ($descr == "") && ($sprite == "")
!return '=='+$label
!endif
!if ($descr == "") && ($sprite != "")
!return $getSprite($sprite)+'\n=='+$label
!endif
!if ($descr != "") && ($sprite == "")
!return '=='+$label+'\n\n '+$descr
!endif
!if ($descr != "") && ($sprite != "")
!return $getSprite($sprite)+'\n=='+$label+'\n\n '+$descr
!endif
!endfunction
!procedure LAYOUT_WITH_LEGEND()
hide stereotype
legend right
|<color:$LEGEND_TITLE_COLOR>**Legend**</color> |
|<$PERSON_BG_COLOR> person |
|<$ROBOT_BG_COLOR> robot |
|<$SYSTEM_BG_COLOR> system |
|<$CONTAINER_BG_COLOR> container |
|<$COMPONENT_BG_COLOR> component |
|<$EXTERNAL_PERSON_BG_COLOR> external person |
|<$EXTERNAL_ROBOT_BG_COLOR> external robot |
|<$EXTERNAL_SYSTEM_BG_COLOR> external system |
|<$EXTERNAL_CONTAINER_BG_COLOR> external container |
|<$EXTERNAL_COMPONENT_BG_COLOR> external component |
endlegend
!endprocedure
LAYOUT_WITH_LEGEND()
Person(user, "Person", "Human User")
Person_Ext(external_user, "External Person", "Another Human User")
Robot(robot, "Robot", "Non-human User")
Robot_Ext(external_robot, "External Robot", "Another Non-human User")
Container(container, "Some Container", "Technology", "Optional Description")
Container_Ext(external_container, "Another Container", "Technology", "Optional Description")
Rel(robot, container, "Label")
Rel(user, container, "Label")
Rel(external_robot, external_container, "Label")
Rel(external_user, external_container, "Label")
@enduml and that's assuming I didn't forget anything (which I probably did). Although I can understand that is not satisfactory, I'm afraid I'm going to have to close this issue as "Won't Fix" |
@Potherca ok I understand. I solved this with this snippet:
Excuse my ignorance: what's the difference with your code above? Of course, in functional terms. What misses my implementation? |
That depends mostly on how much of the underlying functionality you use. My example includes rudimentary support for a Robot(robot, "Robot", "Non-human User")
Robot_Ext(external_robot, "External Robot", "Another Non-human User")
Rel(robot, external_robot, "Label") as well as various configuration options. |
we could add the 2 robot sprites like the person sprites that it can be used like e.g. (external) systems/components. @startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
!include <tupadr3/font-awesome-5/robot.puml>
sprite $robot2 [48x48/16] {
000000000000000088888888888888880000000000000000
000000000000000AFFFFFFFFFFFFFFFFA000000000000000
00000000000000CFFFFFFFFFFFFFFFFFFC00000000000000
00000000000004EFFFFFFFFFFFFFFFFFFE40000000000000
0000000000000AFFFFFFFFFFFFFFFFFFFFA0000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000888FFFFFFFFFFFFFFFFFFFF88800000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000000888FFFFFFFFFFFFFFFFFFFF88800000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000004CFFFFFFFFFFFFFFFFFFC40000000000000
000000488888848CFFFFFFFFFFFFFFFFC848888884000000
00000CFFFFFFFFC888888888888888888CFFFFFFFFC00000
00008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80000
0000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC0000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0000CFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFC0000
00008FFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFF80000
00000CFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFC00000
000000488887578888888888888888888864688884000000
}
AddExternalSystemTag(humanoidRobot, $legendText="humanoid robot (external)", $sprite="robot")
AddSystemTag(cleanroomRobot, $legendText="cleanroom robot", $sprite="robot2")
' only that sprites are displayed in legend too
AddPersonTag(user, $legendText="user", $sprite="person")
AddPersonTag(admin, $legendText="admin", $sprite="person2")
Person(pA, "Person A", $sprite="person", $tags="user")
Person(pB, "Person B", $sprite="person2", $tags="admin")
System_Ext(robA, "Roboter A", $tags="humanoidRobot")
System(robB, "Roboter B", $tags="cleanroomRobot")
SHOW_LEGEND()
@enduml BR Helmut PS.: @dgutson: if you use |
I changed the "robot" sprite, maybe it looks better @startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
sprite $robot [48x48/16] {
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000005BFFFFFFFFFFFFFFFFFFFFFE9100000000000
0000000000AFFFFFFFFFFFFFFFFFFFFFFFFFE30000000000
0000000007FFFFFFFFFFFFFFFFFFFFFFFFFFFE1000000000
000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000000000
000000004FFFFFFFFFFFFFFFFFFFFFFFFFFFFFC000000000
000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFFFD000000000
000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000000
000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000000
000699405FFFFFFC427FFFFFFFFFC427FFFFFFE009982000
008FFF705FFFFFE10006FFFFFFFE00007FFFFFE00FFFF100
00CFFF705FFFFFA00001FFFFFFF900002FFFFFE00FFFF500
00DFFF705FFFFFB00002FFFFFFFA00003FFFFFE00FFFF500
00DFFF705FFFFFF4000AFFFFFFFF3000BFFFFFE00FFFF500
00DFFF705FFFFFFFA8DFFFFFFFFFFA8DFFFFFFE00FFFF500
00DFFF705FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00FFFF500
00DFFF705FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00FFFF500
00DFFF705FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00FFFF500
00DFFF705FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00FFFF500
00DFFF705FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00FFFF500
00CFFF705FFFFFF87777777777777777CFFFFFE00FFFF500
008FFF705FFFFFF100000000000000009FFFFFE00FFFF100
000699405FFFFFF76666666666666666CFFFFFE009982000
000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000000
000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000000
000000004FFFFFFFFFFFFFFFFFFFFFFFFFFFFFC000000000
000000000EFFFFFFFFFFFFFFFFFFFFFFFFFFFF7000000000
0000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFD0000000000
00000000004CFFFFFFFFFFFFFFFFFFFFFFFF910000000000
000000000000011111111111111111111110000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
}
sprite $robot2 [48x48/16] {
000000000000000088888888888888880000000000000000
000000000000000AFFFFFFFFFFFFFFFFA000000000000000
00000000000000CFFFFFFFFFFFFFFFFFFC00000000000000
00000000000004EFFFFFFFFFFFFFFFFFFE40000000000000
0000000000000AFFFFFFFFFFFFFFFFFFFFA0000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000888FFFFFFFFFFFFFFFFFFFF88800000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000
00000000000888FFFFFFFFFFFFFFFFFFFF88800000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000
00000000000004CFFFFFFFFFFFFFFFFFFC40000000000000
000000488888848CFFFFFFFFFFFFFFFFC848888884000000
00000CFFFFFFFFC888888888888888888CFFFFFFFFC00000
00008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80000
0000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC0000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000
0000CFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFC0000
00008FFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFF80000
00000CFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFC00000
000000488887578888888888888888888864688884000000
000000000000000000000000000000000000000000000000
}
AddExternalSystemTag(humanoidRobot, $legendText="humanoid robot (external)", $sprite="robot")
AddSystemTag(cleanroomRobot, $legendText="cleanroom robot", $sprite="robot2")
' only that sprites are displayed in legend too
AddPersonTag(user, $legendText="user", $sprite="person")
AddPersonTag(admin, $legendText="admin", $sprite="person2")
Person(pA, "Person A", $sprite="person", $tags="user")
Person(pB, "Person B", $sprite="person2", $tags="admin")
System_Ext(robA, "Roboter A", $tags="humanoidRobot")
System(robB, "Roboter B", $tags="cleanroomRobot")
SHOW_LEGEND()
@enduml |
Looks good to me. 👍 |
Please allow the Person() macro to specify the shape.
The text was updated successfully, but these errors were encountered: