GithubHelp home page GithubHelp logo

pencil-js / spritesheet Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 0.0 649 KB

🥤 Pack images into a spritesheet.

License: MIT License

JavaScript 100.00%
pencil spritesheet texture-atlas texturepacker tileset

spritesheet's People

Contributors

gmartigny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

spritesheet's Issues

Add an extrude option

Adding 1 (or more ?) pixels around each tiles with the same color as the pixel next to it can avoid tiles edges being poisoned by the outer edges.

This is out of scope for now, but if some people need it, I'll consider adding it.

Usage example

Hey, I just tried the usage example and I got a few errors on node v14.15.0:

  • Must use import to load ES Module
  • ReferenceError: writeFileSync is not defined

Here is a fixed version:

import spritesheet from "@pencil.js/spritesheet";
import fs from "fs";

// List of files to pack
const files = ["image1.png", "image2.jpg", "image3.gif"];
const options = {
    outputFormat: "png",
};
// Call the async function and extract the json and image values
(async () => {
    const { json, image } = await spritesheet(files, options);
    // Write the files (for example)
    fs.writeFileSync("example.png", image);
    fs.writeFileSync("example.json", JSON.stringify(json));
})();

Since you use .mjs I also had to add "type": "module" to my package.json.

Also, this line throws an error Unknown file extension ".json"for me. This may be related to mjs, where importing json is still experimental (https://nodejs.org/api/esm.html#esm_json_modules).

import pkg from "./package.json";

After fixing that and trying to load the spritesheet with PIXI.js I noticed the JSON is missing the meta.image property, which is expected by PIXI to reference the spritesheet file name.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.