forgot unstaged files
This commit is contained in:
parent
d370cf8130
commit
022773d3ab
3 changed files with 58 additions and 0 deletions
BIN
img/tools/cursors/hand.png
Normal file
BIN
img/tools/cursors/hand.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 672 B |
BIN
img/tools/icons/hand.png
Normal file
BIN
img/tools/icons/hand.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 672 B |
58
js/drawingtools/Move.js
Normal file
58
js/drawingtools/Move.js
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* @provide pskl.drawingtools.Move
|
||||||
|
*
|
||||||
|
* @require pskl.utils
|
||||||
|
*/
|
||||||
|
(function() {
|
||||||
|
var ns = $.namespace("pskl.drawingtools");
|
||||||
|
|
||||||
|
ns.Move = function() {
|
||||||
|
this.toolId = "tool-move"
|
||||||
|
|
||||||
|
// Stroke's first point coordinates (set in applyToolAt)
|
||||||
|
this.startCol = null;
|
||||||
|
this.startRow = null;
|
||||||
|
|
||||||
|
this.canvasOverlay = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
pskl.utils.inherit(ns.Move, ns.BaseTool);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @override
|
||||||
|
*/
|
||||||
|
ns.Move.prototype.applyToolAt = function(col, row, color, drawer) {
|
||||||
|
this.startCol = col;
|
||||||
|
this.startRow = row;
|
||||||
|
this.frameClone = drawer.frame.clone();
|
||||||
|
};
|
||||||
|
|
||||||
|
ns.Move.prototype.moveToolAt = function(col, row, color, drawer) {
|
||||||
|
var colDiff = col - this.startCol, rowDiff = row - this.startRow;
|
||||||
|
if (colDiff != 0 || rowDiff != 0) {
|
||||||
|
this.shiftFrame(colDiff, rowDiff, drawer.frame, this.frameClone);
|
||||||
|
drawer.renderFrame();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ns.Move.prototype.shiftFrame = function (colDiff, rowDiff, frame, reference) {
|
||||||
|
var color;
|
||||||
|
for (var col = 0 ; col < frame.getWidth() ; col++) {
|
||||||
|
for (var row = 0 ; row < frame.getHeight() ; row++) {
|
||||||
|
if (reference.containsPixel(col - colDiff, row - rowDiff)) {
|
||||||
|
color = reference.getPixel(col - colDiff, row - rowDiff);
|
||||||
|
} else {
|
||||||
|
color = Constants.TRANSPARENT_COLOR;
|
||||||
|
}
|
||||||
|
frame.setPixel(col, row, color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @override
|
||||||
|
*/
|
||||||
|
ns.Move.prototype.releaseToolAt = function(col, row, color, drawer) {
|
||||||
|
this.moveToolAt(col, row, color, drawer);
|
||||||
|
};
|
||||||
|
})();
|
Loading…
Reference in a new issue