Skip to content

Commit b708b3a

Browse files
committed
Updated
1 parent 0e6824e commit b708b3a

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/main.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,13 @@ const addAttributes = (_element) => {
177177
};
178178

179179
const loadLayerImg = async (_layer) => {
180-
try {
181-
if (_layer.selectedElement.path.includes("-")) {
182-
throw new Error("layer name can not contain dashes");
183-
}
184-
const image = await loadImage(`${_imgObject.path}`);
185-
return {
186-
imgObject: _imgObject,
187-
loadedImage: image,
188-
};
189-
} catch (error) {
190-
console.error("Error loading image:", error);
180+
if (_layer.selectedElement.path.includes("-")) {
181+
throw new Error("layer name can not contain dashes");
191182
}
183+
return new Promise(async (resolve) => {
184+
const image = await loadImage(`${_layer.selectedElement.path}`);
185+
resolve({ layer: _layer, loadedImage: image });
186+
});
192187
};
193188

194189
const addText = (_sig, x, y, size) => {

utils/pixelate.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,15 @@ const getImages = (_dir) => {
3838
};
3939

4040
const loadImgData = async (_imgObject) => {
41-
return new Promise(async (resolve) => {
41+
try {
4242
const image = await loadImage(`${_imgObject.path}`);
43-
resolve({ imgObject: _imgObject, loadedImage: image });
44-
});
43+
return {
44+
imgObject: _imgObject,
45+
loadedImage: image,
46+
};
47+
} catch (error) {
48+
console.error("Error loading image:", error);
49+
}
4550
};
4651

4752
const draw = (_imgObject) => {

0 commit comments

Comments
 (0)