Page 1 of 1
How to change card size in Stock?
Posted: 31 January 2022, 23:11
by chinkes
Hi!
I have high definition card images that are way too big to display at their full resolution. I have them in a Stock for the player's hand. How do I make them smaller? I've tried adding an extra class as described in the Stock documentation and then using background-size for that class in my css file. That does change the size of the card, but then the entire sprite sheet displays instead of the single card.
Thanks!
Re: How to change card size in Stock?
Posted: 01 February 2022, 15:18
by i_a_green
The way I have it working is as follows:
I have a 2500 x 4080 image representing a 5 x 6 array of cards on the sprite sheet (i.e. 30 cards total)
In the css for the stockitem I have :
so this is 1/5th the original size.
Then when I create the stock I use:
Code: Select all
cardwidth = 100;
cardheight = 136;
Which is the size of 1 card after shrinking.
You don't have to shrink it by a whole number ratio, but I think it will probably look better if you do.
Hope that helps.
Re: How to change card size in Stock?
Posted: 01 February 2022, 15:22
by thoun
Why not resize the image? It will also make the file smaller
Re: How to change card size in Stock?
Posted: 01 February 2022, 15:28
by i_a_green
thoun wrote: ↑01 February 2022, 15:22
Why not resize the image? It will also make the file smaller
It will not look as good, especially when you zoom in.
Re: How to change card size in Stock?
Posted: 01 February 2022, 15:28
by Tisaac
i_a_green wrote: ↑01 February 2022, 15:18
I have a 2500 x 4080 image representing a 5 x 6 array of cards on the sprite sheet (i.e. 30 cards total)
You might have trouble on "old" android devices of assets not loading.
Re: How to change card size in Stock?
Posted: 01 February 2022, 15:35
by i_a_green
Tisaac wrote: ↑01 February 2022, 15:28
i_a_green wrote: ↑01 February 2022, 15:18
I have a 2500 x 4080 image representing a 5 x 6 array of cards on the sprite sheet (i.e. 30 cards total)
You might have trouble on "old" android devices of assets not loading.
Interesting. I'm sure I remember a finding a suggested size limit somewhere on the wiki (can't remember if it was pixels or MB) but made sure to resize down enough to come under that limit. Do you know what "old" android devices can handle?
I have some fairly old devices kicking around so I'll be sure to test it on them.
Re: How to change card size in Stock?
Posted: 01 February 2022, 15:41
by i_a_green
Re: How to change card size in Stock?
Posted: 01 February 2022, 15:56
by Tisaac
i_a_green wrote: ↑01 February 2022, 15:35
Tisaac wrote: ↑01 February 2022, 15:28
i_a_green wrote: ↑01 February 2022, 15:18
I have a 2500 x 4080 image representing a 5 x 6 array of cards on the sprite sheet (i.e. 30 cards total)
You might have trouble on "old" android devices of assets not loading.
Interesting. I'm sure I remember a finding a suggested size limit somewhere on the wiki (can't remember if it was pixels or MB) but made sure to resize down enough to come under that limit. Do you know what "old" android devices can handle?
I have some fairly old devices kicking around so I'll be sure to test it on them.
It's pretty hard to find proper documentation on this issue, see for instance this thread :
https://stackoverflow.com/questions/125 ... -in-chrome
It's probably something like "the older the device, the smaller max-size" so it's hard to set a limit but I usually try to keep under 2000px in any direction, it's usually way enough anyway, or I split my sprite if needed.
Re: How to change card size in Stock?
Posted: 01 February 2022, 16:02
by chinkes
Thanks for the replies!
I tried to add pixel size to the background-size of the stockitem as you suggested and it didn't size correctly for some reason (perhaps a mistake on my part). However using percentages worked perfectly. So for my 7 columns and 6 rows sprite sheet I used:
It works great! Thank you!