mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
@ -84,7 +84,9 @@ var Events = {
|
|||||||
CURRENT_FRAME_CHANGED: 'CURRENT_FRAME_CHANGED',
|
CURRENT_FRAME_CHANGED: 'CURRENT_FRAME_CHANGED',
|
||||||
|
|
||||||
CURRENT_LAYER_CHANGED: 'CURRENT_LAYER_CHANGED',
|
CURRENT_LAYER_CHANGED: 'CURRENT_LAYER_CHANGED',
|
||||||
|
|
||||||
CURRENT_PALETTE_CHANGED: 'CURRENT_PALETTE_CHANGED',
|
CURRENT_PALETTE_CHANGED: 'CURRENT_PALETTE_CHANGED',
|
||||||
|
|
||||||
PERFORMANCE_REPORT_CHANGED : 'PERFORMANCE_REPORT_CHANGED',
|
PERFORMANCE_REPORT_CHANGED : 'PERFORMANCE_REPORT_CHANGED',
|
||||||
|
|
||||||
PISKEL_FILE_IMPORT_FAILED : 'PISKEL_FILE_IMPORT_FAILED',
|
PISKEL_FILE_IMPORT_FAILED : 'PISKEL_FILE_IMPORT_FAILED',
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
|
|
||||||
ns.PalettesListController.prototype.selectPalette = function (paletteId) {
|
ns.PalettesListController.prototype.selectPalette = function (paletteId) {
|
||||||
pskl.UserSettings.set(pskl.UserSettings.SELECTED_PALETTE, paletteId);
|
pskl.UserSettings.set(pskl.UserSettings.SELECTED_PALETTE, paletteId);
|
||||||
$.publish(Events.CURRENT_PALETTE_CHANGED);
|
$.publish(Events.CURRENT_PALETTE_CHANGED)
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.PalettesListController.prototype.getSelectedPaletteColors_ = function () {
|
ns.PalettesListController.prototype.getSelectedPaletteColors_ = function () {
|
||||||
@ -182,15 +182,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ns.PalettesListController.prototype.highlightSelectedColors = function () {
|
ns.PalettesListController.prototype.highlightSelectedColors = function () {
|
||||||
var colorPalette = pskl.app.palettesListController.getSelectedPaletteColors_();
|
this.removeClass_(PRIMARY_COLOR_CLASSNAME);
|
||||||
colorPalette.forEach(function(color, index) {
|
this.removeClass_(SECONDARY_COLOR_CLASSNAME);
|
||||||
pskl.app.palettesListController.getColorContainer_(color)
|
|
||||||
.classList.remove(PRIMARY_COLOR_CLASSNAME);
|
|
||||||
pskl.app.palettesListController.getColorContainer_(color)
|
|
||||||
.classList.remove(SECONDARY_COLOR_CLASSNAME);
|
|
||||||
pskl.app.palettesListController.getColorContainer_(color)
|
|
||||||
.classList.remove(CYCLED_COLOR_CLASSNAME);
|
|
||||||
});
|
|
||||||
|
|
||||||
var colorContainer = this.getColorContainer_(pskl.app.selectedColorsService.getSecondaryColor());
|
var colorContainer = this.getColorContainer_(pskl.app.selectedColorsService.getSecondaryColor());
|
||||||
if (colorContainer) {
|
if (colorContainer) {
|
||||||
@ -204,8 +197,7 @@
|
|||||||
colorContainer.classList.add(PRIMARY_COLOR_CLASSNAME);
|
colorContainer.classList.add(PRIMARY_COLOR_CLASSNAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.primaryColorIndex =
|
this.primaryColorIndex = !!primaryColorContainer ? colorPalette.indexOf(pskl.app.selectedColorsService.getPrimaryColor()) : -1;
|
||||||
!!primaryColorContainer ? colorPalette.indexOf(pskl.app.selectedColorsService.getPrimaryColor()) : -1;
|
|
||||||
// Display cycling colors while using the Shift index brush
|
// Display cycling colors while using the Shift index brush
|
||||||
if (!primaryColorContainer || !secondaryColorContainer) { return; }
|
if (!primaryColorContainer || !secondaryColorContainer) { return; }
|
||||||
var startPoint = colorPalette.indexOf(pskl.app.selectedColorsService.getPrimaryColor());
|
var startPoint = colorPalette.indexOf(pskl.app.selectedColorsService.getPrimaryColor());
|
||||||
|
@ -30,9 +30,7 @@
|
|||||||
this.colorsListWidget = new pskl.widgets.ColorsList(colorsListContainer);
|
this.colorsListWidget = new pskl.widgets.ColorsList(colorsListContainer);
|
||||||
|
|
||||||
var palette;
|
var palette;
|
||||||
var isCurrentColorsPalette = paletteId == Constants.CURRENT_COLORS_PALETTE_ID ||
|
var isCurrentColorsPalette = paletteId == Constants.CURRENT_COLORS_PALETTE_ID || paletteId == Constants.CURRENT_FRAME_COLORS_PALETTE_ID;
|
||||||
paletteId == Constants.CURRENT_FRAME_COLORS_PALETTE_ID;
|
|
||||||
|
|
||||||
if (paletteId && !isCurrentColorsPalette) {
|
if (paletteId && !isCurrentColorsPalette) {
|
||||||
importFileButton.style.display = 'none';
|
importFileButton.style.display = 'none';
|
||||||
this.setTitle('Edit Palette');
|
this.setTitle('Edit Palette');
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ns.CurrentColorsService.prototype.getCurrentFrameColors = function () {
|
ns.CurrentColorsService.prototype.getCurrentFrameColors = function () {
|
||||||
return this.currentFrameColors;
|
return this.currentFrameColors
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.CurrentColorsService.prototype.setCurrentColors = function (colors) {
|
ns.CurrentColorsService.prototype.setCurrentColors = function (colors) {
|
||||||
@ -56,30 +56,30 @@
|
|||||||
ns.CurrentColorsService.prototype.updateFrameColors = function (frame) {
|
ns.CurrentColorsService.prototype.updateFrameColors = function (frame) {
|
||||||
frame.colorPalette = [];
|
frame.colorPalette = [];
|
||||||
frame.forEachPixel(function (color, col, row, frame) {
|
frame.forEachPixel(function (color, col, row, frame) {
|
||||||
if (color === 0) {return;}
|
if (color === 0) return;
|
||||||
if (!frame.colorPalette.includes(color)) {
|
if (!frame.colorPalette.includes(color)) {
|
||||||
frame.colorPalette.push(color);
|
frame.colorPalette.push(color)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
// this.currentFrameColors keeps them as hexes, for the palette
|
// this.currentFrameColors keeps them as hexes, for the palette
|
||||||
this.currentFrameColors = frame.colorPalette.map(function(intColor) {
|
this.currentFrameColors = frame.colorPalette.map(function(intColor) {
|
||||||
return pskl.utils.intToHex(intColor);
|
return pskl.utils.intToHex(intColor)
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
ns.CurrentColorsService.prototype.applyCurrentPaletteToIndexedPixels = function (applicationPalette, frame, update) {
|
ns.CurrentColorsService.prototype.applyCurrentPaletteToIndexedPixels = function (applicationPalette, frame, update) {
|
||||||
this.updateFrameColors(frame);
|
this.updateFrameColors(frame);
|
||||||
applicationPalette.forEach(function(color, index) {
|
applicationPalette.forEach(function(color, index) {
|
||||||
frame.forEachPixel(function (oldColor, col, row, frame) {
|
frame.forEachPixel(function (oldColor, col, row, frame) {
|
||||||
if (oldColor === 0) {return;}
|
if (oldColor === 0) return;
|
||||||
var newPixelIndex = frame.colorPalette.indexOf(oldColor);
|
var newPixelIndex = frame.colorPalette.indexOf(oldColor)
|
||||||
if (newPixelIndex === index) {
|
if (newPixelIndex === index) {
|
||||||
frame.setPixel(col, row, color);
|
frame.setPixel(col, row, color);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
};
|
|
||||||
|
|
||||||
ns.CurrentColorsService.prototype.isCurrentColorsPaletteSelected_ = function () {
|
ns.CurrentColorsService.prototype.isCurrentColorsPaletteSelected_ = function () {
|
||||||
var paletteId = pskl.UserSettings.get(pskl.UserSettings.SELECTED_PALETTE);
|
var paletteId = pskl.UserSettings.get(pskl.UserSettings.SELECTED_PALETTE);
|
||||||
|
@ -19,13 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
ns.PaintBucket.prototype.applyToolAt = function(col, row, frame, overlay, event) {
|
ns.PaintBucket.prototype.applyToolAt = function(col, row, frame, overlay, event) {
|
||||||
var color = this.getToolColor();
|
var color = this.getToolColor();
|
||||||
|
pskl.PixelUtils.paintSimilarConnectedPixelsFromFrame(frame, col, row, color);
|
||||||
var sourceOnlyCurrentLayer = pskl.utils.UserAgent.isMac ? event.metaKey : event.ctrlKey;
|
|
||||||
var sourceFrame = frame;
|
|
||||||
if (!sourceOnlyCurrentLayer) {
|
|
||||||
var currentFrameIndex = pskl.app.piskelController.getCurrentFrameIndex();
|
|
||||||
sourceFrame = pskl.utils.LayerUtils.mergeFrameAt(pskl.app.piskelController.getLayers(), currentFrameIndex);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.raiseSaveStateEvent({
|
this.raiseSaveStateEvent({
|
||||||
col : col,
|
col : col,
|
||||||
@ -35,7 +29,6 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ns.PaintBucket.prototype.replay = function (frame, replayData) {
|
ns.PaintBucket.prototype.replay = function (frame, replayData) {
|
||||||
pskl.PixelUtils
|
pskl.PixelUtils.paintSimilarConnectedPixelsFromFrame(frame, replayData.col, replayData.row, replayData.color);
|
||||||
.paintSimilarConnectedPixelsFromFrame(frame, frame, replayData.col, replayData.row, replayData.color);
|
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
ns.PaletteApply = function () {
|
ns.PaletteApply = function () {
|
||||||
this.toolId = 'tool-colorswap';
|
this.toolId = 'tool-colorswap';
|
||||||
this.helpText = 'Apply the currently selected palette\'s colors to a frame via their index numbers';
|
this.helpText = "Apply the currently selected palette's colors to a frame via their index numbers";
|
||||||
this.tooltipDescriptors = [
|
this.tooltipDescriptors = [
|
||||||
{key : 'ctrl', description : 'Apply to all layers'},
|
{key : 'ctrl', description : 'Apply to all layers'},
|
||||||
{key : 'shift', description : 'Apply to all frames'}
|
{key : 'shift', description : 'Apply to all frames'}
|
||||||
@ -18,7 +18,7 @@
|
|||||||
var allFrames = event.shiftKey;
|
var allFrames = event.shiftKey;
|
||||||
|
|
||||||
var currentPalette = pskl.app.palettesListController.getSelectedPaletteColors_();
|
var currentPalette = pskl.app.palettesListController.getSelectedPaletteColors_();
|
||||||
this.swapColors_(currentPalette, allLayers, allFrames);
|
this.swapColors_(currentPalette, allLayers, allFrames)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -31,6 +31,6 @@
|
|||||||
pskl.app.currentColorsService.applyCurrentPaletteToIndexedPixels(newPalette, frame, true);
|
pskl.app.currentColorsService.applyCurrentPaletteToIndexedPixels(newPalette, frame, true);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
};
|
}
|
||||||
|
|
||||||
})();
|
})();
|
Reference in New Issue
Block a user