Scaling of the sprites or images

+1 vote
asked Mar 4, 2016 in Wanted features by habdank (420 points)
Dears,

Is it posible to scale sprite "on the fly".

Actually it is quite unconfortable to generate sprite of the icon for quite much of sizes like 16, 32, 64, 128, 256, ... px.

And then use ONE of those correctly in the diagram.

Is it possible to scale sprite? I mean when I have e.g. sprite with 128 px size, and then I want to have on one diagram something like 16 px icon, and on the other 128 px icon.

 

I had also tried to use <img> HTML tag skipping sprites, as HTML tag (according to W3C) has possibility to scale like:

<img src="icon.png" width="16" height="16">

but this one does not work in PlantUML. I can only use images also without scaling.

<img:icon.png>

 

Do you have some hints?

 

Best regards,

Seweryn.
commented Mar 20, 2017 by stephan (280 points)
Scaling of images is a feature I also would enjoy very much.

Any progress on this? Maybe it is already possible =)

1 Answer

+2 votes
answered Mar 20, 2017 by plantuml (208,360 points)
selected Mar 21, 2017 by habdank
 
Best answer

Yes:  We code, but we forget to document :-)

You can have:

@startuml
sprite $foo1 {
  FFFFFFFFFFFFFFF
  F0123456789ABCF
  F0123456789ABCF
  F0123456789ABCF
  F0123456789ABCF
  F0123456789ABCF
  F0123456789ABCF
  F0123456789ABCF
  F0123456789ABCF
  FFFFFFFFFFFFFFF
}
Alice -> Bob : Testing <$foo1{scale=10}>
@enduml

http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuIekACeiILLGISlFDrIevb9GS4C58143GoDZ4rCpSmjBHoVdGI22vi9QBiUSpEHK1Lqx1QVy90KhXP3KufBCl7G56x2lgekJ4tDIRGqDQksu75BpKe2-1W00

It should be working for image also

commented Mar 20, 2017 by stephan (280 points)
faster than expected =)
thanks a lot
commented Feb 16 by kiyoshih
It works!

But, I cannot scale sprite for stereotype. like this,

@startuml spritescaling
!include <tupadr3/font-awesome-5/amazon>

rectangle "It works." as r1 <<$amazon>> #LightGray
rectangle "It works. <$amazon{scale=2}>" as r2 #LightGray
rectangle "It doesn't work." as r3 <<$amazon{scale=2}>> #LightGray

@enduml
commented Mar 1 by plantuml (208,360 points)
Thanks!
This is fixed in last beta http://beta.plantuml.net/plantuml.jar

Note that you can also use the following syntax :

@startuml
!include <tupadr3/font-awesome-5/amazon>

rectangle "It works." as r1 <<$amazon>> #LightGray
rectangle "It works. <$amazon*2>" as r2 #LightGray
rectangle "It doesn't work." as r3 <<$amazon*2>> #LightGray
@enduml
...