mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Merge pull request #618 from smiegrin/rectanlgeRetool
Improves Rectangle tool performance.
This commit is contained in:
commit
37445202f3
@ -20,10 +20,19 @@
|
||||
* @override
|
||||
*/
|
||||
ns.Rectangle.prototype.draw = function (col, row, color, targetFrame, penSize) {
|
||||
var rectanglePixels = pskl.PixelUtils.getBoundRectanglePixels(this.startCol, this.startRow, col, row);
|
||||
var rectangle = pskl.PixelUtils.getOrderedRectangleCoordinates(this.startCol, this.startRow, col, row);
|
||||
|
||||
pskl.PixelUtils.resizePixels(rectanglePixels, penSize).forEach(function (point) {
|
||||
targetFrame.setPixel(point[0], point[1], color);
|
||||
});
|
||||
for (var x = rectangle.x0; x <= rectangle.x1; x++) {
|
||||
for (var y = rectangle.y0; y <= rectangle.y1; y++) {
|
||||
if (
|
||||
x > rectangle.x1 - penSize ||
|
||||
x < rectangle.x0 + penSize ||
|
||||
y > rectangle.y1 - penSize ||
|
||||
y < rectangle.y0 + penSize
|
||||
) {
|
||||
targetFrame.setPixel(x, y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user