Permits brush size of only 1-32 pixels.

This commit is contained in:
Smie 2016-11-21 12:53:14 -07:00
parent a560872df7
commit 8cb7a4aaf6
3 changed files with 5 additions and 7 deletions

View File

@ -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.

View File

@ -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]);
} }
} }

View File

@ -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);