Last active
August 29, 2015 14:01
-
-
Save vitto/80384a742e0cc6b251e7 to your computer and use it in GitHub Desktop.
Frontsize - How to create a multiple size SVG sprites
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These are 16px sprites | |
<div class="sprites-16 foo"></div> | |
<div class="sprites-16 bar"></div> | |
These are 32px sprites using the same SVG image | |
<div class="sprites-32 foo"></div> | |
<div class="sprites-32 bar"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@spriteWidth: 16px; | |
@spriteHeight: 16px; | |
@backgroundWidth: 512px; | |
@backgroundHeight: 512px; | |
.sprite-16, | |
.sprite-32 { | |
.sprite("sprites-16.svg", @spriteWidth); | |
} | |
.sprite-16 { | |
.setSprite(foo, 0, 0, @spriteWidth, @spriteHeight); | |
.setSprite(bar, 1, 0, @spriteWidth, @spriteHeight); | |
} | |
.sprite-32 { | |
@scale: 2; | |
.scaleSprite(@scale, @spriteWidth, @spriteHeight, @backgroundWidth, @backgroundHeight); | |
.setSprite(foo, 0, 0, @spriteWidth, @spriteHeight, @scale); | |
.setSprite(bar, 1, 0, @spriteWidth, @spriteHeight, @scale); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sprite minixs list