mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Feature : Hold shift to preserve shape ratio
- 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
This commit is contained in:
@@ -83,11 +83,17 @@
|
||||
};
|
||||
|
||||
ns.Frame.prototype.setPixel = function (col, row, color) {
|
||||
this.pixels[col][row] = color;
|
||||
if (this.containsPixel(col, row)) {
|
||||
this.pixels[col][row] = color;
|
||||
}
|
||||
};
|
||||
|
||||
ns.Frame.prototype.getPixel = function (col, row) {
|
||||
return this.pixels[col][row];
|
||||
if (this.containsPixel(col, row)) {
|
||||
return this.pixels[col][row];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
ns.Frame.prototype.forEachPixel = function (callback) {
|
||||
@@ -107,7 +113,7 @@
|
||||
};
|
||||
|
||||
ns.Frame.prototype.containsPixel = function (col, row) {
|
||||
return col >= 0 && row >= 0 && col < this.pixels.length && row < this.pixels[0].length;
|
||||
return col >= 0 && row >= 0 && col < this.width && row < this.height;
|
||||
};
|
||||
|
||||
ns.Frame.prototype.saveState = function () {
|
||||
|
||||
Reference in New Issue
Block a user