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 (270 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 (294,660 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 (270 points)
faster than expected =)
thanks a lot
commented Feb 16, 2019 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, 2019 by plantuml (294,660 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
commented Oct 20, 2020 by julienc

Resizing icons from the standard library also doesn't seem to work in salt.

.tb_button {padding:1px;cursor:pointer;border-right: 1px solid #8b8b8b;border-left: 1px solid #FFF;border-bottom: 1px solid #fff;}.tb_button.hover {borer:2px outset #def; background-color: #f8f8f8 !important;}.ws_toolbar {z-index:100000} .ws_toolbar .ws_tb_btn {cursor:pointer;border:1px solid #555;padding:3px} .tb_highlight{background-color:yellow} .tb_hide {visibility:hidden} .ws_toolbar img {padding:2px;margin:0px}
commented Dec 15, 2021 by Ricardo Reis

I don't see in the above CSS fragment any sizing instructions. All I see a lot of margin and border instructions.

Also, and deriving from over 2 decades' worth of hands-on CSS, I should add that its syntax is usually very unforgiving. Under .tb_button.hover you have borer instead of border. That might be braking something upstream.

...