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_LAYER_CHANGED: 'CURRENT_LAYER_CHANGED',
|
||||
|
||||
CURRENT_PALETTE_CHANGED: 'CURRENT_PALETTE_CHANGED',
|
||||
|
||||
PERFORMANCE_REPORT_CHANGED : 'PERFORMANCE_REPORT_CHANGED',
|
||||
|
||||
PISKEL_FILE_IMPORT_FAILED : 'PISKEL_FILE_IMPORT_FAILED',
|
||||
|
@ -77,7 +77,7 @@
|
||||
|
||||
ns.PalettesListController.prototype.selectPalette = function (paletteId) {
|
||||
pskl.UserSettings.set(pskl.UserSettings.SELECTED_PALETTE, paletteId);
|
||||
$.publish(Events.CURRENT_PALETTE_CHANGED);
|
||||
$.publish(Events.CURRENT_PALETTE_CHANGED)
|
||||
};
|
||||
|
||||
ns.PalettesListController.prototype.getSelectedPaletteColors_ = function () {
|
||||
@ -182,15 +182,8 @@
|
||||
};
|
||||
|
||||
ns.PalettesListController.prototype.highlightSelectedColors = function () {
|
||||
var colorPalette = pskl.app.palettesListController.getSelectedPaletteColors_();
|
||||
colorPalette.forEach(function(color, index) {
|
||||
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);
|
||||
});
|
||||
this.removeClass_(PRIMARY_COLOR_CLASSNAME);
|
||||
this.removeClass_(SECONDARY_COLOR_CLASSNAME);
|
||||
|
||||
var colorContainer = this.getColorContainer_(pskl.app.selectedColorsService.getSecondaryColor());
|
||||
if (colorContainer) {
|
||||
@ -204,8 +197,7 @@
|
||||
colorContainer.classList.add(PRIMARY_COLOR_CLASSNAME);
|
||||
}
|
||||
|
||||
this.primaryColorIndex =
|
||||
!!primaryColorContainer ? colorPalette.indexOf(pskl.app.selectedColorsService.getPrimaryColor()) : -1;
|
||||
this.primaryColorIndex = !!primaryColorContainer ? colorPalette.indexOf(pskl.app.selectedColorsService.getPrimaryColor()) : -1;
|
||||
// Display cycling colors while using the Shift index brush
|
||||
if (!primaryColorContainer || !secondaryColorContainer) { return; }
|
||||
var startPoint = colorPalette.indexOf(pskl.app.selectedColorsService.getPrimaryColor());
|
||||
|
@ -30,9 +30,7 @@
|
||||
this.colorsListWidget = new pskl.widgets.ColorsList(colorsListContainer);
|
||||
|
||||
var palette;
|
||||
var isCurrentColorsPalette = paletteId == Constants.CURRENT_COLORS_PALETTE_ID ||
|
||||
paletteId == Constants.CURRENT_FRAME_COLORS_PALETTE_ID;
|
||||
|
||||
var isCurrentColorsPalette = paletteId == Constants.CURRENT_COLORS_PALETTE_ID || paletteId == Constants.CURRENT_FRAME_COLORS_PALETTE_ID;
|
||||
if (paletteId && !isCurrentColorsPalette) {
|
||||
importFileButton.style.display = 'none';
|
||||
this.setTitle('Edit Palette');
|
||||
|
@ -112,7 +112,7 @@
|
||||
var index = y * this.width + x;
|
||||
var p = this.pixels[index];
|
||||
var color = pskl.utils.colorToInt(entryColor);
|
||||
|
||||
|
||||
if (p !== color) {
|
||||
var applyColor = color || pskl.utils.colorToInt(Constants.TRANSPARENT_COLOR);
|
||||
this.pixels[index] = applyColor;
|
||||
|
@ -32,7 +32,7 @@
|
||||
};
|
||||
|
||||
ns.CurrentColorsService.prototype.getCurrentFrameColors = function () {
|
||||
return this.currentFrameColors;
|
||||
return this.currentFrameColors
|
||||
};
|
||||
|
||||
ns.CurrentColorsService.prototype.setCurrentColors = function (colors) {
|
||||
@ -56,30 +56,30 @@
|
||||
ns.CurrentColorsService.prototype.updateFrameColors = function (frame) {
|
||||
frame.colorPalette = [];
|
||||
frame.forEachPixel(function (color, col, row, frame) {
|
||||
if (color === 0) {return;}
|
||||
if (!frame.colorPalette.includes(color)) {
|
||||
frame.colorPalette.push(color);
|
||||
if (color === 0) return;
|
||||
if (!frame.colorPalette.includes(color)) {
|
||||
frame.colorPalette.push(color)
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
// this.currentFrameColors keeps them as hexes, for the palette
|
||||
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) {
|
||||
this.updateFrameColors(frame);
|
||||
applicationPalette.forEach(function(color, index) {
|
||||
frame.forEachPixel(function (oldColor, col, row, frame) {
|
||||
if (oldColor === 0) {return;}
|
||||
var newPixelIndex = frame.colorPalette.indexOf(oldColor);
|
||||
if (oldColor === 0) return;
|
||||
var newPixelIndex = frame.colorPalette.indexOf(oldColor)
|
||||
if (newPixelIndex === index) {
|
||||
frame.setPixel(col, row, color);
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
ns.CurrentColorsService.prototype.isCurrentColorsPaletteSelected_ = function () {
|
||||
var paletteId = pskl.UserSettings.get(pskl.UserSettings.SELECTED_PALETTE);
|
||||
|
@ -19,13 +19,7 @@
|
||||
*/
|
||||
ns.PaintBucket.prototype.applyToolAt = function(col, row, frame, overlay, event) {
|
||||
var color = this.getToolColor();
|
||||
|
||||
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);
|
||||
};
|
||||
pskl.PixelUtils.paintSimilarConnectedPixelsFromFrame(frame, col, row, color);
|
||||
|
||||
this.raiseSaveStateEvent({
|
||||
col : col,
|
||||
@ -35,7 +29,6 @@
|
||||
};
|
||||
|
||||
ns.PaintBucket.prototype.replay = function (frame, replayData) {
|
||||
pskl.PixelUtils
|
||||
.paintSimilarConnectedPixelsFromFrame(frame, frame, replayData.col, replayData.row, replayData.color);
|
||||
pskl.PixelUtils.paintSimilarConnectedPixelsFromFrame(frame, replayData.col, replayData.row, replayData.color);
|
||||
};
|
||||
})();
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
ns.PaletteApply = function () {
|
||||
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 = [
|
||||
{key : 'ctrl', description : 'Apply to all layers'},
|
||||
{key : 'shift', description : 'Apply to all frames'}
|
||||
@ -18,7 +18,7 @@
|
||||
var allFrames = event.shiftKey;
|
||||
|
||||
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);
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
};
|
||||
}
|
||||
|
||||
})();
|
||||
})();
|
Reference in New Issue
Block a user