Issue #258 : Initial implementation : missing tests + cleanup

This commit is contained in:
jdescottes
2015-11-17 00:19:25 +01:00
parent 4196576c19
commit 222c65a8a5
18 changed files with 257 additions and 41 deletions

View File

@@ -19,18 +19,30 @@
pskl.utils.inherit(ns.SimplePen, ns.BaseTool);
ns.SimplePen.prototype.supportsDynamicPenSize = function() {
return true;
};
/**
* @override
*/
ns.SimplePen.prototype.applyToolAt = function(col, row, frame, overlay, event) {
var color = this.getToolColor();
this.draw(color, col, row, frame, overlay);
};
ns.SimplePen.prototype.draw = function(color, col, row, frame, overlay) {
this.previousCol = col;
this.previousRow = row;
var color = this.getToolColor();
this.drawUsingPenSize(color, col, row, frame, overlay);
};
ns.SimplePen.prototype.drawUsingPenSize = function(color, col, row, frame, overlay) {
var pixels = pskl.app.penSizeService.getPixelsForPenSize(col, row);
pixels.forEach(function (p) {
this.draw(color, p[0], p[1], frame, overlay);
}.bind(this));
};
ns.SimplePen.prototype.draw = function(color, col, row, frame, overlay) {
overlay.setPixel(col, row, color);
if (color === Constants.TRANSPARENT_COLOR) {
frame.setPixel(col, row, color);