mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Removed unused methods from Frame
This commit is contained in:
parent
b3bb2472f1
commit
4102e929f4
@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @provide pskl.drawingtools.ColorSwap
|
||||
*
|
||||
* @require pskl.utils
|
||||
*/
|
||||
(function() {
|
||||
var ns = $.namespace("pskl.drawingtools");
|
||||
@ -19,9 +18,7 @@
|
||||
ns.ColorSwap.prototype.applyToolAt = function(col, row, color, frame, overlay, event) {
|
||||
if (frame.containsPixel(col, row)) {
|
||||
var sampledColor = frame.getPixel(col, row);
|
||||
console.time('swapColors');
|
||||
this.swapColors(sampledColor, color);
|
||||
console.timeEnd('swapColors');
|
||||
|
||||
$.publish(Events.PISKEL_SAVE_STATE, {
|
||||
type : pskl.service.HistoryService.SNAPSHOT
|
||||
@ -30,14 +27,14 @@
|
||||
};
|
||||
|
||||
ns.ColorSwap.prototype.swapColors = function(oldColor, newColor) {
|
||||
var swapPixels = function (pixelColor,x,y,frame) {
|
||||
var swapPixelColor = function (pixelColor,x,y,frame) {
|
||||
if (pixelColor == oldColor) {
|
||||
frame.pixels[x][y] = newColor;
|
||||
}
|
||||
};
|
||||
pskl.app.piskelController.getPiskel().getLayers().forEach(function (l) {
|
||||
l.getFrames().forEach(function (f) {
|
||||
f.forEachPixel(swapPixels);
|
||||
f.forEachPixel(swapPixelColor);
|
||||
f.version++;
|
||||
});
|
||||
});
|
||||
|
@ -96,22 +96,18 @@
|
||||
|
||||
ns.Frame.prototype.getPixel = function (x, y) {
|
||||
if (this.containsPixel(x, y)) {
|
||||
return this._unsafeGetPixel(x,y);
|
||||
return this.pixels[x][y];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
ns.Frame.prototype._unsafeGetPixel = function (x, y) {
|
||||
return this.pixels[x][y];
|
||||
};
|
||||
|
||||
ns.Frame.prototype.forEachPixel = function (callback) {
|
||||
var width = this.getWidth();
|
||||
var height = this.getHeight();
|
||||
for (var col = 0 ; col < width ; col++) {
|
||||
for (var row = 0 ; row < height ; row++) {
|
||||
callback(this._unsafeGetPixel(col, row), col, row, this);
|
||||
for (var x = 0 ; x < width ; x++) {
|
||||
for (var y = 0 ; y < height ; y++) {
|
||||
callback(this.pixels[x][y], x, y, this);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -128,29 +124,6 @@
|
||||
return col >= 0 && row >= 0 && col < this.width && row < this.height;
|
||||
};
|
||||
|
||||
ns.Frame.prototype.saveState = function () {
|
||||
// remove all states past current state
|
||||
this.previousStates.length = this.stateIndex + 1;
|
||||
// push new state
|
||||
this.previousStates.push(this.getPixels());
|
||||
// set the stateIndex to latest saved state
|
||||
this.stateIndex = this.previousStates.length - 1;
|
||||
};
|
||||
|
||||
ns.Frame.prototype.loadPreviousState = function () {
|
||||
if (this.stateIndex > 0) {
|
||||
this.stateIndex--;
|
||||
this.setPixels(this.previousStates[this.stateIndex]);
|
||||
}
|
||||
};
|
||||
|
||||
ns.Frame.prototype.loadNextState = function () {
|
||||
if (this.stateIndex < this.previousStates.length - 1) {
|
||||
this.stateIndex++;
|
||||
this.setPixels(this.previousStates[this.stateIndex]);
|
||||
}
|
||||
};
|
||||
|
||||
ns.Frame.prototype.isSameSize = function (otherFrame) {
|
||||
return this.getHeight() == otherFrame.getHeight() && this.getWidth() == otherFrame.getWidth();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user