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

unpack_tp

v0.0.19

Published

unpack spritesheet for texturepacker

Downloads

6

Readme

unpack_tp

unpack_texturepacker

把texturepacker 生成的图集,重新提取还原成多张小图

安装:

$ npm install unpack_tp

用法命令:

un dir(file) type

dir(file):目录或数据文件

type:文件生成类型(比如cocos就是cc)

API:

/**
 * 解包图集,裁剪还原小图片
 * @param fileOrDir 配置文件绝对路径或文件目录(允许目录嵌套),支持批量处理
 * @param packType 文件类型,非文件后缀,仅提供了cocos支持,类型为 "cc",可通过实现 IParser 接口扩展更多类型
 */
 function unpack(fileOrDir: string, packType: string)

/**
 * 注册自定义解析器
 * @param type string类型
 * @param parserCls 实现了IParser接口的类
 * @param ext 文件扩展名 (".plist")
 */
function registerParser(type: string, parserCls: any, ext:string)

编程式调用:

var unpacker = require("unpack_tp");
var path = require('path');
unpacker.unpack(path.resolve("test", "ui"), "cc");

扩展接口实现

目前仅支持cocos 的plist导出,实现IParser接口可增加支持更多类型

var unpacker = require("unpack_tp");
unpacker.registerParser(IParserCls, "unity");
unpacker.unpack(path.resolve("test", "ui"), "unity");
/**
 * 解析器接口,实现parse方法
 */
export interface IParser {
    /**
     * 解析可能有异步操作,所以要返回 Promise<ITrimData>
     * @param configFilePath 
     */
    parse(configFilePath: string): Promise<ITrimData>
}

/**
 * 图集的裁剪数据
 */
export interface ITrimData {

    /**
     * 图集的绝对路径
     */
    atlasPath: string,

    /**
     * 裁剪数据数组
     */
    itemDatas: ITrimItemData[]
}

/**
 * 裁剪单张图片的所需要数据
 */
export interface ITrimItemData {
    /**
     * 图片名称
     */
    name: string,

    /**
     * 裁剪的时候是否需要旋转
     */
    rotated: boolean,

    /**
     * 旋转的角度
     */
    degree: number,

    /**
     * 真实的裁剪位置与大小,如果是旋转过的,要交换 w,h 的位置
     * [x, y, w, h]
     */
    frame: number[],

    /**
     * 原图像有效像素的矩形
     * [x, y, w, h]
     */
    sourceColorRect: number[],

    /**
     * 原图像的大小
     * [w, h]
     */
    sourceSize: number[]
}

注:需要使用build下的binding.node才能正确裁剪图片,images附带的有问题,第一次运行会自动复制到node_modules/images目录下, 如果不能成功复制文件,需要手动进行操作,images修复后会移除这个步骤,如果运行时有问题,请把nodejs升级到最新版本,作者开发时用的是11.10.0