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

easy-sprite

v0.0.3

Published

A tool that can create spirte image for css.

Downloads

4

Readme

easy-sprite

easy-sprite是一个简洁的css雪碧图制作工具。它能根据指定规则,将小图片合并为雪碧图。easy-sprite采用css注释指定雪碧图合并规则,能够灵活的满足多种需求。支持自动生成低倍率图片,轻松搞定���幕适配。

安装

npm install ease-sprite --save

使用

var sprite = require('ease-sprite');
sprite(options, cb);

配置说明

  • **src:**需要处理的css文件。
  • **dest:**css输出文件名。
  • **spriteDir:**雪碧图输出目录。
  • **margin:**雪碧图排列的最小间距离,默认10px。
  • **compress:**输出css文件是否需要压缩,默认false。
  • **sourcemap:**是否需要输出sourcemap,默认false。

雪碧图声明

雪碧图的声明采用css注释。格式为:/* @sprite:[雪碧图源文件(夹)]=>雪碧图输出文件?selector=背景图调用选择器&alg=图片排列算法 */。

雪碧图源文件的参考路径为当前css路径,雪碧图输出文件的参考路径为spriteDir配置项;生成雪碧图后,需要统一调用背景图,selector参数可以指定调用背景图的选择器。缺省情况下,工具会采用集体声明的方式统一调用背景图;alg参数可以指定图片排列算法,有三个可选值binary、vertical、horizontal。binary为二叉树排列算法、这是一种最节省空间的算法。vertical为从上到下垂直排列。horizontal为从左到右水平排列。在传参时,为了简便可以用首字母代替。

声明示例

/* @sprite:[../img/icon1.png, ../img/icon2.png] => sprite-icon.png?selector=.test */
/* @sprite:[../img/button] => sprite-button.png?alg=v */
.icon{width:10px;height:10px;}
.icon-1{background:url(../img/icon1.png);}
.icon-2{background:url(../img/icon2.png);}
.button1{width:60px; height:30px; background:url(../img/button/1.png);
.button2{width:80px; height:40px; background:url(../img/button/2.png);

sprite 处理后的结果为:

.button1, .button2{background:url(../spriteDir/sprite-button.png);}
.icon{width:10px; height:10px; background-image:url(../spriteDir/sprite-icon.png);}
.icon-1{background-position:0 0;}
.icon-2{background-position:20px 0;}
.button1{width:60px; height:30px; background-position:0, 0;};
.button2{width:80px; height:40px; background-position:0 50px};

可见处理后的css单个背景图调用已经没有了,取而代之是backgroun-position和统一的背景图调用。

关于二倍图

为了适配高分屏,通常需要做两套大小的图片。有了sprite工具,则只需要提供一套大图,sprite工具会压缩出一套小图,并通过media query来决定实际用什么图。支持二倍图非常简单,只需将雪碧图输出文件的命名定为@2x.png、-2x.png或_2x.png,工具在识别出这类雪碧图输出后就会自动生成对应的一倍图和media queery等。

License

MIT:http://vinnyguitar.mit-license.org