pixelkiln 0.47.0 → 0.47.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +25 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +21 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -5
- package/dist/index.d.ts +34 -5
- package/dist/index.js +21 -6
- package/dist/index.js.map +1 -1
- package/docs/ARTIFACTS.md +8 -1
- package/docs/CHARACTERS.md +5 -1
- package/docs/PIXELLAB.md +10 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -14601,15 +14601,27 @@ function packSprites(inputs, options = {}) {
|
|
|
14601
14601
|
const sheetH = rows * cellH;
|
|
14602
14602
|
const rgba = Buffer.alloc(sheetW * sheetH * 4);
|
|
14603
14603
|
const frames = [];
|
|
14604
|
+
const pivot = options.pivot ?? "top-left";
|
|
14604
14605
|
sprites.forEach((sprite, i) => {
|
|
14605
|
-
const
|
|
14606
|
-
const
|
|
14606
|
+
const cellOx = i % columns * cellW;
|
|
14607
|
+
const cellOy = Math.floor(i / columns) * cellH;
|
|
14608
|
+
const offsetX = pivot === "bottom-center" ? Math.floor((cellW - sprite.width) / 2) : 0;
|
|
14609
|
+
const offsetY = pivot === "bottom-center" ? cellH - sprite.height : 0;
|
|
14610
|
+
const ox = cellOx + offsetX;
|
|
14611
|
+
const oy = cellOy + offsetY;
|
|
14607
14612
|
for (let y = 0; y < sprite.height; y++) {
|
|
14608
14613
|
const src = y * sprite.width * 4;
|
|
14609
14614
|
const dst = ((oy + y) * sheetW + ox) * 4;
|
|
14610
14615
|
sprite.pixels.copy(rgba, dst, src, src + sprite.width * 4);
|
|
14611
14616
|
}
|
|
14612
|
-
frames.push({
|
|
14617
|
+
frames.push({
|
|
14618
|
+
id: sprite.id,
|
|
14619
|
+
x: ox,
|
|
14620
|
+
y: oy,
|
|
14621
|
+
width: sprite.width,
|
|
14622
|
+
height: sprite.height,
|
|
14623
|
+
...offsetX || offsetY ? { offsetX, offsetY } : {}
|
|
14624
|
+
});
|
|
14613
14625
|
});
|
|
14614
14626
|
return {
|
|
14615
14627
|
png: encodeRgbaPng(sheetW, sheetH, rgba),
|
|
@@ -15126,12 +15138,15 @@ function renderAsepriteSheet(atlas, opts) {
|
|
|
15126
15138
|
}
|
|
15127
15139
|
const frames = {};
|
|
15128
15140
|
for (const frame of atlas.frames) {
|
|
15141
|
+
const offsetX = frame.offsetX ?? 0;
|
|
15142
|
+
const offsetY = frame.offsetY ?? 0;
|
|
15143
|
+
const pivoted = offsetX !== 0 || offsetY !== 0;
|
|
15129
15144
|
frames[frame.id] = {
|
|
15130
15145
|
frame: { x: frame.x, y: frame.y, w: frame.width, h: frame.height },
|
|
15131
15146
|
rotated: false,
|
|
15132
|
-
trimmed:
|
|
15133
|
-
spriteSourceSize: { x: 0, y: 0, w: frame.width, h: frame.height },
|
|
15134
|
-
sourceSize: { w: frame.width, h: frame.height },
|
|
15147
|
+
trimmed: pivoted,
|
|
15148
|
+
spriteSourceSize: pivoted ? { x: offsetX, y: offsetY, w: frame.width, h: frame.height } : { x: 0, y: 0, w: frame.width, h: frame.height },
|
|
15149
|
+
sourceSize: pivoted ? { w: atlas.cell.width, h: atlas.cell.height } : { w: frame.width, h: frame.height },
|
|
15135
15150
|
duration: durations.get(frame.id) ?? ASEPRITE_DEFAULT_DURATION_MS
|
|
15136
15151
|
};
|
|
15137
15152
|
}
|
|
@@ -15236,16 +15251,18 @@ async function runPack(args) {
|
|
|
15236
15251
|
const manifestDir = path38.dirname(path38.resolve(args.manifest));
|
|
15237
15252
|
const styleIds = args.styles.length ? args.styles : Object.keys(loaded.manifest.styles);
|
|
15238
15253
|
for (const styleId of styleIds) {
|
|
15254
|
+
const style = loaded.manifest.styles[styleId];
|
|
15255
|
+
const pivot = style?.generator === "character" ? "bottom-center" : "top-left";
|
|
15239
15256
|
const packagingSpecs = await resolveSpecs(loaded, { styles: [styleId] });
|
|
15240
15257
|
const qualitySources = await requireApprovedQualitySources(packagingSpecs, lock);
|
|
15241
15258
|
const { png, atlas, skipped, sources } = packStyle(lock, styleId, manifestDir, {
|
|
15242
15259
|
columns: args.columns,
|
|
15243
15260
|
outputRoles: args.outputRoles,
|
|
15244
15261
|
primaryOnly: args.primaryOnly,
|
|
15262
|
+
pivot,
|
|
15245
15263
|
sourceOverrides: qualitySources,
|
|
15246
15264
|
sources: manifestSources(loaded.manifest, styleId)
|
|
15247
15265
|
});
|
|
15248
|
-
const style = loaded.manifest.styles[styleId];
|
|
15249
15266
|
const base = args.out ? path38.resolve(args.out.replace(/\.(?:png|json|tres)$/i, "")) : path38.resolve(manifestDir, style.outDir, `${styleId}-sheet`);
|
|
15250
15267
|
const format = sheetFormat(args);
|
|
15251
15268
|
const { extension, document } = renderSheetDocument(format, atlas, { imageName: path38.basename(`${base}.png`) });
|
|
@@ -15272,6 +15289,7 @@ async function runPack(args) {
|
|
|
15272
15289
|
format,
|
|
15273
15290
|
order: "id",
|
|
15274
15291
|
outputRoles: [...args.outputRoles].sort(),
|
|
15292
|
+
pivot,
|
|
15275
15293
|
primaryOnly: args.primaryOnly,
|
|
15276
15294
|
style: styleId
|
|
15277
15295
|
}
|