2012-09-12 10:01:47 +00:00
|
|
|
(function () {
|
|
|
|
var ns = $.namespace("pskl.selection");
|
|
|
|
|
|
|
|
ns.BaseSelection = function () {
|
2012-09-13 20:57:32 +00:00
|
|
|
this.reset();
|
|
|
|
};
|
|
|
|
|
|
|
|
ns.BaseSelection.prototype.reset = function () {
|
2012-09-12 10:01:47 +00:00
|
|
|
this.pixels = [];
|
2012-09-14 23:01:47 +00:00
|
|
|
this.hasPastedContent = false;
|
2012-09-12 10:01:47 +00:00
|
|
|
};
|
|
|
|
|
2012-09-13 20:57:32 +00:00
|
|
|
ns.BaseSelection.prototype.move = function (colDiff, rowDiff) {
|
|
|
|
var movedPixel, movedPixels = [];
|
|
|
|
|
|
|
|
for(var i=0, l=this.pixels.length; i<l; i++) {
|
|
|
|
movedPixel = this.pixels[i];
|
|
|
|
movedPixel.col += colDiff;
|
|
|
|
movedPixel.row += rowDiff;
|
2013-05-27 21:42:53 +00:00
|
|
|
movedPixels.push(movedPixel);
|
2012-09-13 20:57:32 +00:00
|
|
|
}
|
|
|
|
this.pixels = movedPixels;
|
|
|
|
};
|
2012-09-12 10:01:47 +00:00
|
|
|
|
2012-09-13 20:57:32 +00: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 =
|
2013-05-27 21:42:53 +00:00
|
|
|
targetFrame.getPixel(pixelWithCopiedColor.col, pixelWithCopiedColor.row);
|
2012-09-12 10:01:47 +00:00
|
|
|
}
|
2012-09-14 23:01:47 +00:00
|
|
|
this.hasPastedContent = true;
|
2012-09-12 10:01:47 +00:00
|
|
|
};
|
|
|
|
})();
|