[FEAT] UX enhancements
This commit is contained in:
@@ -37,6 +37,16 @@ export const useLayers = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const updateSpriteInLayer = (layerId: string, spriteId: string, x: number, y: number) => {
|
||||
const l = layers.value.find(layer => layer.id === layerId);
|
||||
if (!l) return;
|
||||
const i = l.sprites.findIndex(s => s.id === spriteId);
|
||||
if (i !== -1) {
|
||||
l.sprites[i].x = Math.floor(x);
|
||||
l.sprites[i].y = Math.floor(y);
|
||||
}
|
||||
};
|
||||
|
||||
const alignSprites = (position: 'left' | 'center' | 'right' | 'top' | 'middle' | 'bottom') => {
|
||||
const l = activeLayer.value;
|
||||
if (!l || !l.sprites.length) return;
|
||||
@@ -138,9 +148,7 @@ export const useLayers = () => {
|
||||
img.src = url;
|
||||
};
|
||||
|
||||
const addSprite = (file: File) => addSpriteWithResize(file);
|
||||
|
||||
const addSpriteWithResize = (file: File) => {
|
||||
const addSprite = (file: File) => {
|
||||
const l = activeLayer.value;
|
||||
if (!l) return;
|
||||
const url = URL.createObjectURL(file);
|
||||
@@ -163,7 +171,7 @@ export const useLayers = () => {
|
||||
};
|
||||
|
||||
const processImageFiles = async (files: File[]) => {
|
||||
for (const f of files) addSpriteWithResize(f);
|
||||
for (const f of files) addSprite(f);
|
||||
};
|
||||
|
||||
const addLayer = (name?: string) => {
|
||||
@@ -203,11 +211,11 @@ export const useLayers = () => {
|
||||
columns,
|
||||
getMaxDimensions,
|
||||
updateSpritePosition,
|
||||
updateSpriteInLayer,
|
||||
updateSpriteCell,
|
||||
removeSprite,
|
||||
replaceSprite,
|
||||
addSprite,
|
||||
addSpriteWithResize,
|
||||
processImageFiles,
|
||||
alignSprites,
|
||||
addLayer,
|
||||
|
||||
Reference in New Issue
Block a user