piskel/js/drawingtools/VerticalMirrorPen.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

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