mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Allows square brush size of up to 1,000,000 pixels using keyboard shortcuts.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
var ns = $.namespace('pskl.service.pensize');
|
var ns = $.namespace('pskl.service.pensize');
|
||||||
|
|
||||||
var MIN_PENSIZE = 1;
|
var MIN_PENSIZE = 1;
|
||||||
var MAX_PENSIZE = 4;
|
var MAX_PENSIZE = 1000000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to retrieve and modify the current pen size.
|
* Service to retrieve and modify the current pen size.
|
||||||
|
|||||||
@@ -76,33 +76,20 @@
|
|||||||
*
|
*
|
||||||
* @param {Number} row x-coordinate of the original pixel
|
* @param {Number} row x-coordinate of the original pixel
|
||||||
* @param {Number} col y-coordinate of the original pixel
|
* @param {Number} col y-coordinate of the original pixel
|
||||||
* @param {Number} size >= 1 && <= 4
|
* @param {Number} size >= 1 && <= 1000000
|
||||||
* @return {Array} array of arrays of 2 Numbers (eg. [[0,0], [0,1], [1,0], [1,1]])
|
* @return {Array} array of arrays of 2 Numbers (eg. [[0,0], [0,1], [1,0], [1,1]])
|
||||||
*/
|
*/
|
||||||
resizePixel : function (col, row, size) {
|
resizePixel : function (col, row, size) {
|
||||||
if (size == 1) {
|
var pixels = [];
|
||||||
return [[col, row]];
|
if(size > 1000000) size = 1000000;
|
||||||
} else if (size == 2) {
|
|
||||||
return [
|
for(j = 0; j < size; j++) {
|
||||||
[col, row], [col + 1, row],
|
for(i = 0; i < size; i++) {
|
||||||
[col, row + 1], [col + 1, row + 1]
|
pixels.push([col-Math.floor(size/2)+i,row-Math.floor(size/2)+j]);
|
||||||
];
|
|
||||||
} else if (size == 3) {
|
|
||||||
return [
|
|
||||||
[col - 1, row - 1], [col, row - 1], [col + 1, row - 1],
|
|
||||||
[col - 1, row + 0], [col, row + 0], [col + 1, row + 0],
|
|
||||||
[col - 1, row + 1], [col, row + 1], [col + 1, row + 1],
|
|
||||||
];
|
|
||||||
} else if (size == 4) {
|
|
||||||
return [
|
|
||||||
[col - 1, row - 1], [col, row - 1], [col + 1, row - 1], [col + 2, row - 1],
|
|
||||||
[col - 1, row + 0], [col, row + 0], [col + 1, row + 0], [col + 2, row + 0],
|
|
||||||
[col - 1, row + 1], [col, row + 1], [col + 1, row + 1], [col + 2, row + 1],
|
|
||||||
[col - 1, row + 2], [col, row + 2], [col + 1, row + 2], [col + 2, row + 2],
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
console.error('Unsupported size : ' + size);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pixels;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user