npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-tamia-sprite

v0.3.1

Published

Sprite generator for Tâmia.

Downloads

16

Readme

Sprite generator for Tâmia

Build Status

Generates spritesheet from PNG files and a list of Stylus variables with coordinates to use in Tâmia. Uses spritesmith. Inspired by grunt-spritesmith.

Installation

This plugin requires Grunt 0.4.

npm install --save-dev grunt-tamia-sprite

Add to your Gruntfile.js:

grunt.loadNpmTasks('grunt-tamia-sprite');

Then add section named sprite inside grunt.initConfig(). See next section for details.

Parameters

src

Type: String|Array.

Images list (PNG only). String or array. Wildcards are supported.

dest

Type: String.

Resulting sprite image location.

Options

Options should be inside options object:

sprite: {
	all: {
		src: 'images/sprites/*.png',
		dest: 'build/sprite.png'
		options: {
			destStyl: 'styles/sprite.styl'
		}
	}
}

destStyl

Type: String, default: same as dest but with .styl extension.

Resulting Stylus file location. Use false to disable Stylus file generation.

destJson

Type: String, default: same as dest but with .json extension.

Resulting JSON file location. Use false to disable JSON file generation.

template

Type: String, default: '{%=target%}_{%=name%} = {%=x%}px {%=y%}px {%=width%}px {%=height%}px'.

Template for generating every string in a Stylus file.

fingerprintTemplate

Type: String, default: '{%=target%}_fingerprint = "{%=fingerprint%}"'.

Template for variable with fingerpting (date of last sprite modification).

sprite_image = sprite_image + '?' + sprite_fingerprint;

propertyTemplate

Type: String, default: '{%=target%}_{%=name%} = {%=value%}px'.

Template for spritesheet properties variables (width & height).

background-size: sprite_width sprite_height;

algorithm

Type: String, default: 'binary-tree'

Layout algorithm (top-down, left-right, diagonal, alt-diagonal, binary-tree).

padding

Type: String, default: 3.

Padding between images.

engine

Type: String, default: 'auto'

Generation engine (auto, gm, canvas).

Gruntfile Example

module.exports = function(grunt) {
	grunt.initConfig({
		sprite: {
			all: {
				src: 'images/sprites/*.png',
				dest: 'build/sprite.png'
			}
		}
	});
	grunt.loadNpmTasks('grunt-tamia-sprite');
	grunt.registerTask('default', ['sprite']);
};

Stylus Example (with nib & vars from JSON file)

sprite = json("sprite.json", { hash: true })
.sprite
	image("sprite.png", sprite.properties.width * 1px, sprite.properties.height * 1px)

	for name, data in sprite.coordinates
		&_{name}
			add-property("background-position", data.x * 1px data.y * 1px)
			add-property("width", data.width * 1px)
			add-property("height", data.height * 1px)

Changelog

The changelog can be found in the Changelog.md file.


License

The MIT License, see the included License.md file.