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

multi-sprite

v0.2.4

Published

Create multi-sprites and updates css, support 2x 3x sprite generator

Downloads

7

Readme

multi-sprite

一个自动合并css图片的模块,支持合并2x、3x、多切片文件夹的情况。

##安装 npm install multi-sprite

使用

require('multi-sprite')(configs)

详见:测试例子

configs

  • rootFontSize: rem单位值,切换成rem处理方式时需要设置改值,默认 750/16。当css切片宽度使用rem单位时,切换成rem处理方式。
  • srcImg: 切片文件夹,比如 src/slice
  • srcCss: 引用切片的样式文件夹,比如 src/css
  • destImg: 输出的雪碧图文件夹,比如dest/img/sprite
  • destCss: 输出的样式文件夹,比如dest/css
  • algorithm: 雪碧图的排序算法,支持:top-down, left-right, diagonal, alt-diagonal, binary-tree。默认值 binary-tree
  • padding: 切片间隙像素值,默认值0
  • engine: 图片处理引擎,支持:auto, canvas, gm,默认值gm
  • exportOpts: 导出图片的格式信息
    • format: 支持:png, jpg,默认值png
    • quality: gm引擎的png质量控制,如90
  • successCB: 图片和样式处理完成后的回调函数

切片约定

  • 配置项 configs.srcImg 为切片文件夹,可内建子文件夹,一个子文件夹对应一张雪碧图
  • 切片如有 @2x, @3x 尾缀的图片,将生成对应高清的雪碧图
  • 每个@2x 切片像素值是偶数;每个@3x 切片像素值是3的倍数;

样式约定

  • 参与合并图片的样式,使用语法 background-image:url() 引入切片
  • @2x, @3x 尾缀的图片名字与1倍图保持一致,多倍图切片不需要引入样式表,multi-sprite 会自动加上 媒体查询代码片段
  • 可参考 测试的@3x例子

##历史

  • 0.2.0 对css的更新操作使用 reworkcss/css,替代正则替换
  • 0.1.9 增加rem 处理方式
  • 0.1.6 修复win32 下雪碧图样式替换失效问题
  • 0.1.4 支持3x图片合并
  • 0.0.3 配置参数增加,执行成功后的回调
  • 0.0.1 支持2x、多雪碧图合并