mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-11 10:39:56 -05:00
Why do our lint rules require such weird formatting
This commit is contained in:
parent
998c5a186e
commit
2bd468950f
2 changed files with 42 additions and 44 deletions
|
@ -86,8 +86,7 @@ const fetchBitmapCanvas_ = function (costume, rotationCenter) {
|
|||
loadedOne = true;
|
||||
}
|
||||
baseImageElement.src = costume.asset.encodeDataURI();
|
||||
})
|
||||
.then(imageElements => {
|
||||
}).then(imageElements => {
|
||||
const [baseImageElement, textImageElement] = imageElements;
|
||||
|
||||
const canvas = document.createElement('canvas');
|
||||
|
@ -118,12 +117,12 @@ const fetchBitmapCanvas_ = function (costume, rotationCenter) {
|
|||
assetMatchesBase: scale !== 1 || textImageElement.src
|
||||
};
|
||||
})
|
||||
.catch(e => Promise.reject(e))
|
||||
.finally(() => {
|
||||
// Clean up the costume object
|
||||
delete costume.textLayerMD5;
|
||||
delete costume.textLayerAsset;
|
||||
});
|
||||
.catch(e => Promise.reject(e))
|
||||
.finally(() => {
|
||||
// Clean up the costume object
|
||||
delete costume.textLayerMD5;
|
||||
delete costume.textLayerAsset;
|
||||
});
|
||||
};
|
||||
|
||||
const loadBitmap_ = function (costume, runtime, rotationCenter) {
|
||||
|
@ -148,22 +147,22 @@ const loadBitmap_ = function (costume, runtime, rotationCenter) {
|
|||
}
|
||||
resolve(fetched.canvas);
|
||||
}))
|
||||
.catch(e => Promise.reject(e))
|
||||
.then(canvas => {
|
||||
// createBitmapSkin does the right thing if costume.bitmapResolution or rotationCenter are undefined...
|
||||
costume.skinId = runtime.renderer.createBitmapSkin(canvas, costume.bitmapResolution, rotationCenter);
|
||||
const renderSize = runtime.renderer.getSkinSize(costume.skinId);
|
||||
costume.size = [renderSize[0] * 2, renderSize[1] * 2]; // Actual size, since all bitmaps are resolution 2
|
||||
.catch(e => Promise.reject(e))
|
||||
.then(canvas => {
|
||||
// createBitmapSkin does the right thing if costume.bitmapResolution or rotationCenter are undefined...
|
||||
costume.skinId = runtime.renderer.createBitmapSkin(canvas, costume.bitmapResolution, rotationCenter);
|
||||
const renderSize = runtime.renderer.getSkinSize(costume.skinId);
|
||||
costume.size = [renderSize[0] * 2, renderSize[1] * 2]; // Actual size, since all bitmaps are resolution 2
|
||||
|
||||
if (!rotationCenter) {
|
||||
rotationCenter = runtime.renderer.getSkinRotationCenter(costume.skinId);
|
||||
// Actual rotation center, since all bitmaps are resolution 2
|
||||
costume.rotationCenterX = rotationCenter[0] * 2;
|
||||
costume.rotationCenterY = rotationCenter[1] * 2;
|
||||
costume.bitmapResolution = 2;
|
||||
}
|
||||
return costume;
|
||||
});
|
||||
if (!rotationCenter) {
|
||||
rotationCenter = runtime.renderer.getSkinRotationCenter(costume.skinId);
|
||||
// Actual rotation center, since all bitmaps are resolution 2
|
||||
costume.rotationCenterX = rotationCenter[0] * 2;
|
||||
costume.rotationCenterY = rotationCenter[1] * 2;
|
||||
costume.bitmapResolution = 2;
|
||||
}
|
||||
return costume;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -81,8 +81,7 @@ const deserializeCostume = function (costume, runtime, zip, assetFileName, textL
|
|||
costume.asset.dataFormat,
|
||||
new Uint8Array(Object.keys(costume.asset.data).map(key => costume.asset.data[key])),
|
||||
costume.asset.assetId
|
||||
))
|
||||
.then(asset => {
|
||||
)).then(asset => {
|
||||
costume.asset = asset;
|
||||
});
|
||||
}
|
||||
|
@ -123,31 +122,31 @@ const deserializeCostume = function (costume, runtime, zip, assetFileName, textL
|
|||
return Promise.resolve(null);
|
||||
}
|
||||
textLayerFilePromise = textLayerFile.async('uint8array')
|
||||
.then(data => storage.createAsset(
|
||||
storage.AssetType.ImageBitmap,
|
||||
'png',
|
||||
data,
|
||||
costume.textLayerMD5
|
||||
))
|
||||
.then(asset => {
|
||||
costume.textLayerAsset = asset;
|
||||
});
|
||||
.then(data => storage.createAsset(
|
||||
storage.AssetType.ImageBitmap,
|
||||
'png',
|
||||
data,
|
||||
costume.textLayerMD5
|
||||
))
|
||||
.then(asset => {
|
||||
costume.textLayerAsset = asset;
|
||||
});
|
||||
} else {
|
||||
textLayerFilePromise = Promise.resolve(null);
|
||||
}
|
||||
|
||||
return Promise.all([textLayerFilePromise,
|
||||
costumeFile.async('uint8array')
|
||||
.then(data => storage.createAsset(
|
||||
assetType,
|
||||
// TODO eventually we want to map non-png's to their actual file types?
|
||||
costumeFormat,
|
||||
data,
|
||||
assetId
|
||||
))
|
||||
.then(asset => {
|
||||
costume.asset = asset;
|
||||
})
|
||||
.then(data => storage.createAsset(
|
||||
assetType,
|
||||
// TODO eventually we want to map non-png's to their actual file types?
|
||||
costumeFormat,
|
||||
data,
|
||||
assetId
|
||||
))
|
||||
.then(asset => {
|
||||
costume.asset = asset;
|
||||
})
|
||||
]);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue