From 2bd468950f40135cb0dbf29ac3f71f1cf7021d5c Mon Sep 17 00:00:00 2001 From: DD Date: Tue, 6 Nov 2018 16:54:41 -0500 Subject: [PATCH] Why do our lint rules require such weird formatting --- src/import/load-costume.js | 45 ++++++++++++------------- src/serialization/deserialize-assets.js | 41 +++++++++++----------- 2 files changed, 42 insertions(+), 44 deletions(-) diff --git a/src/import/load-costume.js b/src/import/load-costume.js index 851d0bf4c..accbb5a31 100644 --- a/src/import/load-costume.js +++ b/src/import/load-costume.js @@ -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; + }); }; /** diff --git a/src/serialization/deserialize-assets.js b/src/serialization/deserialize-assets.js index 71e8fe346..4e0a0bafa 100644 --- a/src/serialization/deserialize-assets.js +++ b/src/serialization/deserialize-assets.js @@ -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; + }) ]); };