4. PassSpriteAsParameter¶
4.1. Understand How To Pass A Sprite To A Procedure¶
4.1.1. Source¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | @startuml
'create equivalent of icons shown here https://github.com/awslabs/aws-icons-for-plantuml
sprite $Batch [64x64/16z] {
xLQ7bjim30CdzFzVtEV1iErPkJpT7iYm5aWDKERujFZ5Bp8YkSvM011VfMzSDy2Mw1JidbCGAtmllmbPuIkoImjyGUsyBV4LV95_Xny50bpW4uTRAjOKu81b
Xa0vbX3OKFG5C0IMNLyxXA_3PvW5hqHSOFBP_Ovk4036hYi0pJdTCgqD6A0g4FQ0hOwygxSikGOanw11AuvtomxXjNiRDECmn21xxTkJP0N4tdy1Gmu5T2GW
6ygFL_sqbx3NvA_FVtt_ri_F1CZNra-10TpNhvVr2KGcyVCOdoBySlpv-jC1ZSVveO36_Fwb0UASqGqG0QpfJgP2Eo60u59-fLVozhhdNk2WTeDpq2O6AAL_
uV7KGPNO2lya17gz1pMiD1VmFNH9IBLNe3xA3q07eNsMy_WdXESwU4jRmddEk-FUuPFjjthiqAEGVUz8rlqmsK1nhtYlklvp7vWRfka0jUNITUdTzgxFyzLx
-Ikh_YdmYr_y0G
}
!procedure $SpritePass2($MySprite)
rectangle "<$MySprite>\n2" as 2
!endprocedure
$SpritePass2("$Batch")
@enduml
|
4.2. Understand How To Pass A Sprite To A Procedure - using unquoted keyword¶
This option uses the unquoted keyword. The caller of the procedure does not need to add quotes when calling the procedure.
4.2.1. Source¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | @startuml
'create equivalent of icons shown here https://github.com/awslabs/aws-icons-for-plantuml
sprite $Batch [64x64/16z] {
xLQ7bjim30CdzFzVtEV1iErPkJpT7iYm5aWDKERujFZ5Bp8YkSvM011VfMzSDy2Mw1JidbCGAtmllmbPuIkoImjyGUsyBV4LV95_Xny50bpW4uTRAjOKu81b
Xa0vbX3OKFG5C0IMNLyxXA_3PvW5hqHSOFBP_Ovk4036hYi0pJdTCgqD6A0g4FQ0hOwygxSikGOanw11AuvtomxXjNiRDECmn21xxTkJP0N4tdy1Gmu5T2GW
6ygFL_sqbx3NvA_FVtt_ri_F1CZNra-10TpNhvVr2KGcyVCOdoBySlpv-jC1ZSVveO36_Fwb0UASqGqG0QpfJgP2Eo60u59-fLVozhhdNk2WTeDpq2O6AAL_
uV7KGPNO2lya17gz1pMiD1VmFNH9IBLNe3xA3q07eNsMy_WdXESwU4jRmddEk-FUuPFjjthiqAEGVUz8rlqmsK1nhtYlklvp7vWRfka0jUNITUdTzgxFyzLx
-Ikh_YdmYr_y0G
}
!unquoted procedure $SpritePass2($MySprite)
rectangle "<$MySprite>\n2" as 2
!endprocedure
$SpritePass2($Batch)
@enduml
|
4.3. Use Procedure Defaults¶
And Tidy Up The Procedure So It’s Easier To Read
4.3.1. Source¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
@startuml
sprite $Batch [64x64/16z] {
xLQ7bjim30CdzFzVtEV1iErPkJpT7iYm5aWDKERujFZ5Bp8YkSvM011VfMzSDy2Mw1JidbCGAtmllmbPuIkoImjyGUsyBV4LV95_Xny50bpW4uTRAjOKu81b
Xa0vbX3OKFG5C0IMNLyxXA_3PvW5hqHSOFBP_Ovk4036hYi0pJdTCgqD6A0g4FQ0hOwygxSikGOanw11AuvtomxXjNiRDECmn21xxTkJP0N4tdy1Gmu5T2GW
6ygFL_sqbx3NvA_FVtt_ri_F1CZNra-10TpNhvVr2KGcyVCOdoBySlpv-jC1ZSVveO36_Fwb0UASqGqG0QpfJgP2Eo60u59-fLVozhhdNk2WTeDpq2O6AAL_
uV7KGPNO2lya17gz1pMiD1VmFNH9IBLNe3xA3q07eNsMy_WdXESwU4jRmddEk-FUuPFjjthiqAEGVUz8rlqmsK1nhtYlklvp7vWRfka0jUNITUdTzgxFyzLx
-Ikh_YdmYr_y0G
}
!unquoted procedure $ffoo5($alias, $description="", $label="", $technology="", $scale=1, $colour="red")
rectangle rect5 as "
<<$alias>>
==$label==
<color:$colour><$Batch*$scale></color>
//<size:12>[$technology]</size>//
$description 556"
!endprocedure
$ffoo5(myalias, "description\non several lines", $scale=2)
@enduml
|
4.4. So What?¶
We said previously that the current stdlib macros are largely the same across files - changing for each icon.
So now we have a way to define a procedure(s) in one place, and pass an icon.