D
D
Denis Bukreev2017-01-26 05:37:12
css
Denis Bukreev, 2017-01-26 05:37:12

Is it possible to make a sprite scalable?

So it goes.
I create sprites with SpriteSmith.
And such a thing: at resolutions from 640 to 320, the layout is fully scalable (all sizes are written in vw), but the sprites remain the same size, always.
In addition, they are made for retina screens.
Is it possible to make the sprite scale as well?
Or will you have to display all the icons in img?
The designer did not provide SVG, so there is no need to write about them.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2017-01-26
@tusklozeleniy

Raster scaling is a bad idea. However, if there is a need, then you need to set the background-position for the icons as a percentage. SpriteSmith, judging by a cursory examination, does not know how to do this, so you have to fork or calculate the percentages yourself.
UPD: You need to change the background-position and background-size, of course. background-size is better to change in pixels.
UPD2: I looked again, you can not take a steam bath, modify result.coordinates.

result.coordinates.x = (result.coordinates.x / result.properties.width) * 100;
result.coordinates.y = (result.coordinates.y / result.properties.height) * 100;

The same goes for the height-width of the sprite. Plus, make sure that he inserts the values ​​​​in%, and not in px

P
Pavel, 2017-01-26
@Carduelis

Perhaps my article will help you, there is about scaling, sprites and all that
https://habrahabr.ru/post/196030/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question