Azure-PlantUML
Azure-PlantUML copied to clipboard
How to use the colored version of icons?
I take advantage of the last activities on this repo to ask for this question : how to use the colored version of icons ?
Is this now possible ?
This prevents me to use PlantUML as it full potential ...
Originally posted by @ChrisProlls in https://github.com/plantuml-stdlib/Azure-PlantUML/issues/20#issuecomment-1006379981
Hi Just an upvote here as i was planning to also use colored icons. However i'm not able to figure out how to exactly use them in plantuml.
I'm breaking my head on it as it is unclear. If it is possible to use the Color versions instead of the Mono than can we add examples to the repository readme ?
Thanks for creating the issue.
I don't believe this is currently possible. According to the PlantUML documentation, sprites are monochrome. When invoking PlantUML to create the sprite, it'll be converted to greyscale automatically unless another color is specified. The end result will always be monochrome. This can be confirmed by creating a sprite using a full color icon:
java -Djava.awt.headless=true -jar scripts/plantuml.jar -encodesprite 16z dist/Compute/AzureDisk.png
The resulting sprite is greyscale:
@startuml color-demo
sprite $AzureDisk [70x70/16z] {
xTO73jmm30LH5CEVf07e_hUDe1HbLlOIOdgP0pmNrVQ__vqljRtKEszJh-MP928har8IbHN96RCKcTc3iON8xCOvh9SWOEo6iHo18HiTgw9C8J8YygIePvBf
7d5FNqKUronyLTmzG_nwBOYi2f5HN4ihuZ4LlniV-SN2gBXJYOaWcKV45JqtYSYgnCQi9GB5CsG6X4fu4Q4IleNOGAXu34SPCfLXGEb5qCb_RG21qXtB4VDX
t2iJaeZCI0o43FDX0Pa_0mgPIcsjWdmxu-sXab67slji30k7aqEdxE0_C4s-h1KVcGrWH8YTczKDLaNOKKPO0Iagwjb8Kiey6CPKKMpjlQAdLyaLuxnV4ntf
J9JivWC1oDSAc8r4nQe85LC5eJAg65Is7HaGCDAMiIg0KW8AcPmI121WO253GC1irzRg1giZh4YiLOcrkf1RxTVqlmy
}
Alice -> Bob : Testing <$AzureDisk>
@enduml

Although the sprites themselves are monochrome, there are various ways in which color can be used:
- Using the color tag:
<color:orange><$sprite>
- Using the sprite's color attribute:
<$sprite,color=orange>
- Setting the background color of the container a sprite is in:
rectangle "<$sprite>" #orange
Sadly, using a gradient on the container does not work well with the sprite's background (see example below).
PlantUML Diagram Source
@startuml
!$AzurePuml="https://raw.githubusercontent.com/plantuml-stdlib/Azure-PlantUML/release/2-1/dist"
!include $AzurePuml/AzureCommon.puml
!include $AzurePuml/Storage/AzureDiskStorage.puml
rectangle "default Sprite" as a {
rectangle "<$AzureDiskStorage>" as a1
}
rectangle "<color:...>" as b {
rectangle "<color:orange><$AzureDiskStorage>" as b1
rectangle "<color:blue><$AzureDiskStorage>" as b2
}
rectangle "<$sprite,color=...>" as c {
rectangle "<$AzureDiskStorage,color=orange>" as c1
rectangle "<$AzureDiskStorage,color=blue>" as c2
}
rectangle "Container Color" as d {
rectangle "<$AzureDiskStorage>" as d1 #orange
rectangle "<$AzureDiskStorage>" as d2 #blue
}
rectangle "Sprite Color and Container Color" as e {
rectangle "<$AzureDiskStorage,color=orange>" as e1 #blue
rectangle "<$AzureDiskStorage,color=blue>" as e2 #orange
}
rectangle "Container Gradient" as f {
rectangle "<$AzureDiskStorage,color=blue>" as f1 #orange|blue
rectangle "<$AzureDiskStorage,color=blue>" as f2 #orange|blue
rectangle "<$AzureDiskStorage,color=blue>" as f3 #orange|blue
rectangle "<$AzureDiskStorage,color=blue>" as f4 #orange|blue
}
a -[hidden]-> b
b -[hidden]> c
b -[hidden]-> d
d -[hidden]> e
d -[hidden]-> f
@enduml