Why sprites don't show in a C4 diagram

0 votes
asked Apr 7 in Question / help by Josh (140 points)
Using this code or any variation, the sprite is not drawn. It only shows the sprit reference.
@startuml
!define RECTANGLE class
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml

' Define a simple sprite with explicit size and graylevel=4
sprite $cloudLogo [8x8/4] {
F F F F F F F F
F F 6 6 6 6 F F
F 6 6 6 6 6 6 F
6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6
F 6 6 6 6 6 6 F
F F 6 6 6 6 F F
F F F F F F F F
}

' System with the sprite
System(mySystem, "My System", "A sample system", $sprite=$cloudLogo)

Person(user, "User", "A system user")
Rel(user, mySystem, "Uses")

SHOW_LEGEND()
@enduml

1 Answer

0 votes
answered Apr 7 by The-Lu (85,820 points)

Hello J,

Just suppress the dollar on the sprite System call, as:

@startuml
!define RECTANGLE class
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml

' Define a simple sprite with explicit size and graylevel=4
sprite $cloudLogo [8x8/4] {
F F F F F F F F
F F 6 6 6 6 F F
F 6 6 6 6 6 6 F
6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6
F 6 6 6 6 6 6 F
F F 6 6 6 6 F F
F F F F F F F F
}

' System with the sprite
System(mySystem, "My System", "A sample system", $sprite=cloudLogo)

Person(user, "User", "A system user")
Rel(user, mySystem, "Uses")

SHOW_LEGEND()
@enduml

But it seems there are some other issues...

Enjoy,
Regards,
Th.

commented Apr 7 by kirchsth (7,760 points)

Maybe it is simpler to use the 16 gray scales instead of 4 (I couldn't find the 4 scale encoding details). And if you have small (or big) sprites you can scale it up (or down) too

the image is linked with the source



BR Helmut

commented Apr 7 by plantuml (297,300 points)
Maybe you could take advantage of "Inline SVG sprite" ?

https://plantuml.com/sprite#5fa6c1055e0d0960

Even if they are SVG defined, they do work with PNG
...