Spritemapper: CSS sprite map generator using simulated annealing
yostudios.github.com
yostudios.github.com
However, they are often hand crafted, but there have been in existence many tools that try to do the same thing as "spritemapper" (google results, there may be better ones out there):
- http://spritegen.website-performance.org/
But most of them are shitty web interface tools and not very well suited for a scriptable developer environment.
This is why I like this implementation. It seems nice, I'll probably try it on my next project.
Runs as a bookmarklet.
> It is a common practice used by most front end developers
I think you are too optimistic there. The practice is not new indeed (the famous http://www.alistapart.com/articles/sprites was published 7 years ago) but so far I don't see many sites using it or any other simple front-end performance improving techniques.1. It should only write the URL of the background image once, and only background-position on the rest.
2. The most widely used width/height should be specified as the default and width/height properties only included when it differs.
Also, to avoid the need of any padding between the images you can emulate background-crop with pseudo elements (http://nicolasgallagher.com/css-background-image-hacks/).
It doesn't use simulated annealing, which is pretty neat, but it does generate really well packed pngs:
sf --layout packed --pngcrush awesome/
Leads to 87x80 at 6,873 bytes vs 103x92 at 7,237 bytes on the awesome image font demo. It will also output either sass or css.(on a side note, has anyone compared this with SmartSprites?)
† You can only do either x-repeating or y-repeating in a given sprite, and everything that needs to repeat must extend from edge to edge
Here's my implementation of Jim Scott's lightmap packing algorithm (http://www.blackpawn.com/texts/lightmaps/default.html): http://www.joelverhagen.com/blog/2011/03/jim-scotts-packing-... if you're interested.
Obviously the two improvements aren't necessarily linked, but in the short term they're going to be mostly used together when Google controls both ends of the connection.