| A Sprite is a small graphic element that can be used in diagrams. In PlantUML, sprites are monochrome and can have either 4, 8 or 16 gray level. To define a sprite, you have to use a hexadecimal digit between 0 and F per pixel. Then you can use the sprite using |
<$XXX> where XXX is the name of the sprite. You can scale the sprite. You can also use inlined SVG for sprites. Only a tiny subset of SVG directives is possible, so you probably have to compress existing SVG files using either: Another example:
Although sprites are monochrome, it's possible to change their color.
To encode sprite, you can use the command line like:
java -jar plantuml.jar -encodesprite 16z foo.png
foo.png is the image file you want to use (it will be converted to gray automatically). After
-encodesprite, you have to specify a format:
4, 8, 16, 4z, 8z or
16z. The number indicates the gray level and the optional
z is used to enable compression in sprite definition. You can also launch the GUI to generate a sprite from an existing image. Click in the menubar then on
File/Open Sprite Window. After copying an image into you clipboard, several possible definitions of the corresponding sprite will be displayed : you will just have to pickup the one you want.
The PlantUML StdLib includes a number of ready icons in various IT areas such as architecture, cloud services, logos etc. It including AWS, Azure, Kubernetes, C4, product Logos and many others. To explore these libraries: sprites-list. (The next section shows how to list selected sprites but unfortunately that's in grayscale whereas this custom listing is in color.) You can use the
listsprites command to show available sprites: (Example from Hitchhikers Guide to PlantUML) Most collections have files called
all that allow you to see a whole sub-collection at once. Else you need to find the sprites that interest you and include them one by one. Unfortunately, the version of a collection included in StdLib often does not have such
all files, so as you see above we include the collection from github, not from StdLib. All sprites are in grayscale, but most collections define specific macros that include appropriate (vendor-specific) colors.