
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Minimum module to create spritesheet dynamically.
Currently, it is mostly for creating pixi.js spritesheet.
npm install speet
<script src="path/to/speet.js"></script>
<script>
const imageList = {
player: "./assets/player.png",
enemy: "./assets/enemy.png",
}
speet.generate(imageList)
.then((ss)=> {
console.log(ss.data); // json of sprite frame data
document.body.appendChild(ss.image);
})
</script>
import {generate} from "speet";
const imageList = {
player: "./assets/player.png",
enemy: "./assets/enemy.png",
};
(async ()=> {
const { image: ssImage, data: ssData } = await generate(imageList)
console.log(ssData); // json of sprite frame data
document.body.appendChild(ssImage);
})();
import {generate} from "speet";
function createPixiSpriteSheet(image, dataJson) {
return new Promise((resolve)=> {
const baseTexture = PIXI.BaseTexture.from(image);
const ss = new PIXI.Spritesheet(baseTexture, dataJson);
ss.parse(()=> resolve(ss))
})
}
const imageList = {
player: "./assets/player.png",
enemy: "./assets/enemy.png",
};
(async ()=> {
// pixi app
const app = new PIXI.Application();
document.body.appendChild(app.view);
const interaction = app.renderer.plugins.interaction;
// Create pixi spritesheet
const baseSS = await speet.generate(imageList, { forcePOT: true });
const pixiSS = await createPixiSpriteSheet(baseSS.image, baseSS.data);
// Add sprite using spritesheet
const spr = new PIXI.Sprite(pixiSS.textures["player"]);
app.stage.addChild(spr);
interaction.on('pointerdown', (e) => {
spr.position.set(e.data.global.x, e.data.global.y)
});
})();
(async ()=> {
const ss = await speet.generate(imageList, {
padding: 4,
border: 4,
forcePOT: true,
formatter: (sprites) => {
return sprites.map((s)=> {
return {
x: s.x,
y: s.y,
w: s.width,
h: s.height,
}
})
}
});
console.log(ss.data); // array of objects with x, y, w, h property
})();
| Name | Type | Description | Default |
|---|---|---|---|
| padding | number | Sets padding between sprites. | 2 |
| border | number | Sets border padding at the edges of spritesheet. | 0 |
| forcePOT | boolean | Force spritesheet size to be power of two (e.g. 512x512). This option is for optimization of GPU-powered graphic system (mostly WebGL). | false |
| formatter | function | Sets your own formatting function for spritesheet data json. | undefined |
Instead of image path string, you can also pass dataURI string, HTMLImageElement, or HTMLCanvasElement.
function createCanvasRect(w, h) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = w;
canvas.height = h;
ctx.fillStyle = "#D93788";
ctx.fillRect(0, 0, w, h);
return canvas;
}
const imageList = {
eggplant: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADcAAAAtCAMAAAA9SAOJAAAAYFBMVEUAAAAiIDRFKDxmOTGPVjvfcSbZoGbuw5r78jaZ5VBqvjA3lG5LaS9SSyQyPDk/P3QwYIJbbuFjm/9fzeTL2/z///+brbeEfodpampZVlJ2QoqsMjLZV2PXe7qPl0qKbzD7Y7zPAAAAIHRSTlMA/////////////////////////////////////////5KarXYAAACqSURBVEiJ7dOxDsMgDEVRZhg8ZXn//6F1qFAqgm2eo3bqDVOUI1tCKeXfs2prv3W15sbpk2LnybBOM+N4V6EEtGutO4XkPOBktMOIu3pcJRnhgITDHPu9JpFbIWW+W6PImUqZBOw49Gj7DrYTx9lLdha5ecPBxF/TdPyaknOPGOvkYowL2cqJxGx28hkcVywUsGKgt/J+2OW88WrL3XOYB11mykgt7R76ei8wAEus0oBkTgAAAABJRU5ErkJggg=="
canvasRect: createCanvasRect(128, 128),
}
speet.generate(imageList)
Sprite packing algorithm is inspired by bertrand_a's idea.
FAQs
Simple dynamic spritesheet generator for web app
We found that speet demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.