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:
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @provide pskl.drawingtools.ColorSwap
|
* @provide pskl.drawingtools.ColorSwap
|
||||||
*
|
*
|
||||||
* @require pskl.utils
|
|
||||||
*/
|
*/
|
||||||
(function() {
|
(function() {
|
||||||
var ns = $.namespace("pskl.drawingtools");
|
var ns = $.namespace("pskl.drawingtools");
|
||||||
@@ -19,9 +18,7 @@
|
|||||||
ns.ColorSwap.prototype.applyToolAt = function(col, row, color, frame, overlay, event) {
|
ns.ColorSwap.prototype.applyToolAt = function(col, row, color, frame, overlay, event) {
|
||||||
if (frame.containsPixel(col, row)) {
|
if (frame.containsPixel(col, row)) {
|
||||||
var sampledColor = frame.getPixel(col, row);
|
var sampledColor = frame.getPixel(col, row);
|
||||||
console.time('swapColors');
|
|
||||||
this.swapColors(sampledColor, color);
|
this.swapColors(sampledColor, color);
|
||||||
console.timeEnd('swapColors');
|
|
||||||
|
|
||||||
$.publish(Events.PISKEL_SAVE_STATE, {
|
$.publish(Events.PISKEL_SAVE_STATE, {
|
||||||
type : pskl.service.HistoryService.SNAPSHOT
|
type : pskl.service.HistoryService.SNAPSHOT
|
||||||
@@ -30,14 +27,14 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ns.ColorSwap.prototype.swapColors = function(oldColor, newColor) {
|
ns.ColorSwap.prototype.swapColors = function(oldColor, newColor) {
|
||||||
var swapPixels = function (pixelColor,x,y,frame) {
|
var swapPixelColor = function (pixelColor,x,y,frame) {
|
||||||
if (pixelColor == oldColor) {
|
if (pixelColor == oldColor) {
|
||||||
frame.pixels[x][y] = newColor;
|
frame.pixels[x][y] = newColor;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
pskl.app.piskelController.getPiskel().getLayers().forEach(function (l) {
|
pskl.app.piskelController.getPiskel().getLayers().forEach(function (l) {
|
||||||
l.getFrames().forEach(function (f) {
|
l.getFrames().forEach(function (f) {
|
||||||
f.forEachPixel(swapPixels);
|
f.forEachPixel(swapPixelColor);
|
||||||
f.version++;
|
f.version++;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -96,22 +96,18 @@
|
|||||||
|
|
||||||
ns.Frame.prototype.getPixel = function (x, y) {
|
ns.Frame.prototype.getPixel = function (x, y) {
|
||||||
if (this.containsPixel(x, y)) {
|
if (this.containsPixel(x, y)) {
|
||||||
return this._unsafeGetPixel(x,y);
|
return this.pixels[x][y];
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.Frame.prototype._unsafeGetPixel = function (x, y) {
|
|
||||||
return this.pixels[x][y];
|
|
||||||
};
|
|
||||||
|
|
||||||
ns.Frame.prototype.forEachPixel = function (callback) {
|
ns.Frame.prototype.forEachPixel = function (callback) {
|
||||||
var width = this.getWidth();
|
var width = this.getWidth();
|
||||||
var height = this.getHeight();
|
var height = this.getHeight();
|
||||||
for (var col = 0 ; col < width ; col++) {
|
for (var x = 0 ; x < width ; x++) {
|
||||||
for (var row = 0 ; row < height ; row++) {
|
for (var y = 0 ; y < height ; y++) {
|
||||||
callback(this._unsafeGetPixel(col, row), col, row, this);
|
callback(this.pixels[x][y], x, y, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -128,29 +124,6 @@
|
|||||||
return col >= 0 && row >= 0 && col < this.width && row < this.height;
|
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) {
|
ns.Frame.prototype.isSameSize = function (otherFrame) {
|
||||||
return this.getHeight() == otherFrame.getHeight() && this.getWidth() == otherFrame.getWidth();
|
return this.getHeight() == otherFrame.getHeight() && this.getWidth() == otherFrame.getWidth();
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user