mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Permits brush size of only 1-32 pixels.
This commit is contained in:
parent
a560872df7
commit
8cb7a4aaf6
@ -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 = 1000000;
|
var MAX_PENSIZE = 32;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to retrieve and modify the current pen size.
|
* Service to retrieve and modify the current pen size.
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
*
|
*
|
||||||
* @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 && <= 1000000
|
* @param {Number} size >= 1 && <= 32
|
||||||
* @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) {
|
||||||
@ -84,11 +84,9 @@
|
|||||||
var i;
|
var i;
|
||||||
var j;
|
var j;
|
||||||
|
|
||||||
if (size > 1000000) { size = 1000000; }
|
|
||||||
|
|
||||||
for (j = 0; j < size; j++) {
|
for (j = 0; j < size; j++) {
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
pixels.push([col - Math.floor(size / 2) + i,row - Math.floor(size / 2) + j]);
|
pixels.push([col - Math.floor(size / 2) + i, row - Math.floor(size / 2) + j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ describe("PenSize test suite", function() {
|
|||||||
|
|
||||||
penSizeService.init();
|
penSizeService.init();
|
||||||
// MAX_VALUE is 4
|
// MAX_VALUE is 4
|
||||||
penSizeService.setPenSize(5);
|
penSizeService.setPenSize(33);
|
||||||
expect(penSizeService.getPenSize()).toBe(1);
|
expect(penSizeService.getPenSize()).toBe(1);
|
||||||
// MIN_VALUE is 1
|
// MIN_VALUE is 1
|
||||||
penSizeService.setPenSize(0);
|
penSizeService.setPenSize(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user