2012-09-16 02:49:52 +04:00
|
|
|
(function() {
|
2013-08-10 14:11:16 +04:00
|
|
|
var ns = $.namespace("pskl.drawingtools");
|
|
|
|
|
|
|
|
ns.VerticalMirrorPen = function() {
|
|
|
|
this.toolId = "tool-vertical-mirror-pen";
|
|
|
|
this.helpText = "vertical mirror pen tool";
|
|
|
|
|
|
|
|
this.swap = null;
|
|
|
|
this.mirroredPreviousCol = null;
|
|
|
|
this.mirroredPreviousRow = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
pskl.utils.inherit(ns.VerticalMirrorPen, ns.SimplePen);
|
2013-09-29 01:52:51 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
|
|
|
|
ns.VerticalMirrorPen.prototype.setMirrorContext = function() {
|
|
|
|
this.swap = this.previousCol;
|
|
|
|
this.previousCol = this.mirroredPreviousCol;
|
|
|
|
};
|
|
|
|
|
|
|
|
ns.VerticalMirrorPen.prototype.unsetMirrorContext = function() {
|
|
|
|
this.mirroredPreviousCol = this.previousCol;
|
|
|
|
this.previousCol = this.swap;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
2013-12-06 01:12:48 +04:00
|
|
|
ns.VerticalMirrorPen.prototype.applyToolAt = function(col, row, color, frame, overlay, event) {
|
2013-08-10 14:11:16 +04:00
|
|
|
this.superclass.applyToolAt.call(this, col, row, color, frame, overlay);
|
|
|
|
|
|
|
|
var mirroredCol = this.getSymmetricCol_(col, frame);
|
|
|
|
this.mirroredPreviousCol = mirroredCol;
|
|
|
|
|
|
|
|
this.setMirrorContext();
|
|
|
|
this.superclass.applyToolAt.call(this, mirroredCol, row, color, frame, overlay);
|
|
|
|
this.unsetMirrorContext();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
ns.VerticalMirrorPen.prototype.getSymmetricCol_ = function(col, frame) {
|
2013-09-29 01:52:51 +04:00
|
|
|
return frame.getWidth() - col - 1;
|
2013-08-10 14:11:16 +04:00
|
|
|
};
|
2012-09-16 02:49:52 +04:00
|
|
|
})();
|