diff --git a/js/ColorModule.js b/js/ColorModule.js index cbf5fe1..f2ce578 100644 --- a/js/ColorModule.js +++ b/js/ColorModule.js @@ -346,6 +346,7 @@ const ColorModule = (() => { * @param {*} paletteColors The colours of the palette */ function createColorPalette(paletteColors) { + console.log("creating palette"); //remove current palette while (colorsMenu.childElementCount > 1) colorsMenu.children[0].remove(); @@ -389,6 +390,9 @@ const ColorModule = (() => { */ function createPaletteFromLayers() { let colors = {}; + let nColors = 0; + //create array out of colors object + let colorPaletteArray = []; for (let i=0; i { for (let j=0; j= settings.maxColorsOnImportedImage) { - alert('The image loaded seems to have more than '+settings.maxColorsOnImportedImage+' colors.'); + if (nColors >= Settings.getCurrSettings().maxColorsOnImportedImage) { + alert('The image loaded seems to have more than '+Settings.getCurrSettings().maxColorsOnImportedImage+' colors.'); break; } } @@ -413,18 +418,10 @@ const ColorModule = (() => { } } - //create array out of colors object - let colorPaletteArray = []; - for (let color in colors) { - if (colors.hasOwnProperty(color)) { - colorPaletteArray.push('#'+Color.rgbToHex(colors[color])); - } - } - - console.log("palette"); - //create palette from colors array createColorPalette(colorPaletteArray); + + console.log("Done 2"); } function updateCurrentColor(color, refLayer) { diff --git a/js/History.js b/js/History.js index 47033ae..39b3272 100644 --- a/js/History.js +++ b/js/History.js @@ -38,8 +38,8 @@ const History = (() => { undoStates.push(state); //limit the number of states to settings.numberOfHistoryStates - if (undoStates.length > settings.numberOfHistoryStates) { - undoStates = undoStates.splice(-settings.numberOfHistoryStates, settings.numberOfHistoryStates); + if (undoStates.length > Settings.getCurrSettings().numberOfHistoryStates) { + undoStates = undoStates.splice(-Settings.getCurrSettings().numberOfHistoryStates, Settings.getCurrSettings().numberOfHistoryStates); } //there is now definitely at least 1 undo state, so the button shouldnt be disabled diff --git a/js/Settings.js b/js/Settings.js index ba8a13a..8c16843 100644 --- a/js/Settings.js +++ b/js/Settings.js @@ -57,7 +57,12 @@ const Settings = (() => { Dialogue.closeDialogue(); } - return { - + function getCurrSettings() { + return settings; } + + return { + getCurrSettings + } + })(); \ No newline at end of file diff --git a/js/_pixelEditorUtility.js b/js/_pixelEditorUtility.js index 6800839..c696e60 100644 --- a/js/_pixelEditorUtility.js +++ b/js/_pixelEditorUtility.js @@ -6,16 +6,8 @@ * @param {*} pixel */ function isPixelEmpty(pixel) { - if (pixel == null || pixel === undefined) { - return false; - } - // If the alpha channel is 0, the current pixel is empty - if (pixel[3] == 0) { - return true; - } - - return false; + return pixel[3] == 0; } // REFACTOR: move to eyedropper onMouseUp event? diff --git a/js/_pixelGrid.js b/js/_pixelGrid.js index 6fb2833..6a49c64 100644 --- a/js/_pixelGrid.js +++ b/js/_pixelGrid.js @@ -66,7 +66,7 @@ function fillPixelGrid() { pixelGrid.canvas.width = originalSize[0] * Math.round(lineDistance); pixelGrid.canvas.height = originalSize[1] * Math.round(lineDistance); - context.strokeStyle = settings.pixelGridColour; + context.strokeStyle = Settings.getCurrSettings().pixelGridColour; // OPTIMIZABLE, could probably be a bit more elegant // Draw horizontal lines