[FEAT] Calc. fixes
This commit is contained in:
@@ -20,10 +20,11 @@ export const useExportLayers = (layersRef: Ref<Layer[]>, columns: Ref<number>, n
|
||||
};
|
||||
}
|
||||
|
||||
// Otherwise, calculate from sprite dimensions
|
||||
const visibleLayers = getVisibleLayers();
|
||||
const { maxWidth, maxHeight } = getMaxDimensionsAcrossLayers(visibleLayers);
|
||||
const negativeSpacing = calculateNegativeSpacing(getAllVisibleSprites(), negativeSpacingEnabled.value);
|
||||
// Otherwise, calculate from sprite dimensions across ALL layers (same as canvas)
|
||||
// This ensures export dimensions match what's shown in the canvas
|
||||
const { maxWidth, maxHeight } = getMaxDimensionsAcrossLayers(layersRef.value);
|
||||
const allSprites = getVisibleLayers().flatMap(l => l.sprites);
|
||||
const negativeSpacing = calculateNegativeSpacing(allSprites, negativeSpacingEnabled.value);
|
||||
return {
|
||||
cellWidth: maxWidth + negativeSpacing,
|
||||
cellHeight: maxHeight + negativeSpacing,
|
||||
|
||||
@@ -356,8 +356,9 @@ export const useLayers = () => {
|
||||
};
|
||||
};
|
||||
|
||||
export const getMaxDimensionsAcrossLayers = (layers: Layer[]) => {
|
||||
// Consider ALL layers regardless of visibility to keep canvas size stable
|
||||
const sprites = layers.flatMap(l => l.sprites);
|
||||
export const getMaxDimensionsAcrossLayers = (layers: Layer[], visibleOnly: boolean = false) => {
|
||||
// When visibleOnly is false (default), consider ALL layers to keep canvas size stable
|
||||
// When visibleOnly is true (export), only consider visible layers
|
||||
const sprites = layers.flatMap(l => (visibleOnly ? (l.visible ? l.sprites : []) : l.sprites));
|
||||
return getMaxDimensionsSingle(sprites);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user