2012-09-12 14:01:47 +04:00
|
|
|
(function () {
|
2013-11-25 22:00:19 +04:00
|
|
|
var ns = $.namespace("pskl.selection");
|
2012-09-12 14:01:47 +04:00
|
|
|
|
2013-11-25 22:00:19 +04:00
|
|
|
ns.BaseSelection = function () {
|
|
|
|
this.reset();
|
|
|
|
};
|
2012-09-14 00:57:32 +04:00
|
|
|
|
2013-11-25 22:00:19 +04:00
|
|
|
ns.BaseSelection.prototype.reset = function () {
|
|
|
|
this.pixels = [];
|
|
|
|
this.hasPastedContent = false;
|
|
|
|
};
|
2012-09-12 14:01:47 +04:00
|
|
|
|
2013-11-25 22:00:19 +04:00
|
|
|
ns.BaseSelection.prototype.move = function (colDiff, rowDiff) {
|
|
|
|
var movedPixel, movedPixels = [];
|
2012-09-14 00:57:32 +04:00
|
|
|
|
2013-11-25 22:00:19 +04:00
|
|
|
for(var i=0, l=this.pixels.length; i<l; i++) {
|
|
|
|
movedPixel = this.pixels[i];
|
|
|
|
movedPixel.col += colDiff;
|
|
|
|
movedPixel.row += rowDiff;
|
|
|
|
movedPixels.push(movedPixel);
|
|
|
|
}
|
|
|
|
this.pixels = movedPixels;
|
|
|
|
};
|
2012-09-12 14:01:47 +04:00
|
|
|
|
2013-11-25 22:00:19 +04:00
|
|
|
ns.BaseSelection.prototype.fillSelectionFromFrame = function (targetFrame) {
|
|
|
|
var pixelWithCopiedColor;
|
|
|
|
for(var i=0, l=this.pixels.length; i<l; i++) {
|
|
|
|
pixelWithCopiedColor = this.pixels[i];
|
|
|
|
pixelWithCopiedColor.copiedColor =
|
|
|
|
targetFrame.getPixel(pixelWithCopiedColor.col, pixelWithCopiedColor.row);
|
|
|
|
}
|
|
|
|
this.hasPastedContent = true;
|
|
|
|
};
|
2012-09-12 14:01:47 +04:00
|
|
|
})();
|