2012-09-15 22:49:52 +00:00
|
|
|
(function() {
|
|
|
|
var ns = $.namespace("pskl.drawingtools");
|
|
|
|
|
2012-09-15 22:52:39 +00:00
|
|
|
ns.VerticalMirrorPen = function() {
|
2012-09-15 22:49:52 +00:00
|
|
|
this.toolId = "tool-vertical-mirror-pen";
|
2012-09-15 22:52:39 +00:00
|
|
|
this.helpText = "vertical mirror pen tool";
|
2012-09-15 22:49:52 +00:00
|
|
|
|
2013-05-27 21:42:53 +00:00
|
|
|
this.swap = null;
|
2012-09-15 22:49:52 +00:00
|
|
|
this.mirroredPreviousCol = null;
|
2013-05-27 21:42:53 +00:00
|
|
|
this.mirroredPreviousRow = null;
|
2012-09-15 22:49:52 +00:00
|
|
|
};
|
|
|
|
|
2012-09-15 22:52:39 +00:00
|
|
|
pskl.utils.inherit(ns.VerticalMirrorPen, ns.SimplePen);
|
2012-09-15 22:49:52 +00:00
|
|
|
|
|
|
|
|
2012-09-15 22:52:39 +00:00
|
|
|
ns.VerticalMirrorPen.prototype.setMirrorContext = function() {
|
2012-09-15 22:49:52 +00:00
|
|
|
this.swap = this.previousCol;
|
|
|
|
this.previousCol = this.mirroredPreviousCol;
|
|
|
|
};
|
|
|
|
|
2012-09-15 22:52:39 +00:00
|
|
|
ns.VerticalMirrorPen.prototype.unsetMirrorContext = function() {
|
2012-09-15 22:49:52 +00:00
|
|
|
this.mirroredPreviousCol = this.previousCol;
|
|
|
|
this.previousCol = this.swap;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
2012-09-15 22:52:39 +00:00
|
|
|
ns.VerticalMirrorPen.prototype.applyToolAt = function(col, row, color, frame, overlay) {
|
2012-09-15 22:49:52 +00: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
|
|
|
|
*/
|
2012-09-15 22:52:39 +00:00
|
|
|
ns.VerticalMirrorPen.prototype.getSymmetricCol_ = function(col, frame) {
|
2012-09-15 22:49:52 +00:00
|
|
|
return frame.getWidth() - col - 1;
|
|
|
|
};
|
|
|
|
})();
|