mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
c9251229fc
- mutualized shape tools common code in a ShapeTool class - when holding shift and drawing a frame, the ratio is preserved - selection and shape tools now support the mouse to leave the drawing area - shape tools can go 'outside' the drawing canvas - Frame set/getPixel now check the pixel is in range instead of crashing
26 lines
671 B
JavaScript
26 lines
671 B
JavaScript
/**
|
|
* @provide pskl.drawingtools.Rectangle
|
|
*
|
|
* @require pskl.utils
|
|
*/
|
|
(function() {
|
|
var ns = $.namespace("pskl.drawingtools");
|
|
|
|
ns.Rectangle = function() {
|
|
ns.ShapeTool.call(this);
|
|
|
|
this.toolId = "tool-rectangle";
|
|
this.helpText = "Rectangle tool";
|
|
};
|
|
|
|
pskl.utils.inherit(ns.Rectangle, ns.ShapeTool);
|
|
|
|
ns.Rectangle.prototype.draw_ = function (col, row, color, targetFrame) {
|
|
var strokePoints = pskl.PixelUtils.getBoundRectanglePixels(this.startCol, this.startRow, col, row);
|
|
for(var i = 0; i< strokePoints.length; i++) {
|
|
// Change model:
|
|
targetFrame.setPixel(strokePoints[i].col, strokePoints[i].row, color);
|
|
}
|
|
};
|
|
})();
|