From 8cb7a4aaf6c86fc3b94fae3048f8c8c1b06dff4f Mon Sep 17 00:00:00 2001 From: Smie Date: Mon, 21 Nov 2016 12:53:14 -0700 Subject: [PATCH] Permits brush size of only 1-32 pixels. --- src/js/service/pensize/PenSizeService.js | 2 +- src/js/utils/PixelUtils.js | 6 ++---- test/js/service/pensize/PenSizeServiceTest.js | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/js/service/pensize/PenSizeService.js b/src/js/service/pensize/PenSizeService.js index d2b3fbc1..9a3f7b2f 100644 --- a/src/js/service/pensize/PenSizeService.js +++ b/src/js/service/pensize/PenSizeService.js @@ -2,7 +2,7 @@ var ns = $.namespace('pskl.service.pensize'); var MIN_PENSIZE = 1; - var MAX_PENSIZE = 1000000; + var MAX_PENSIZE = 32; /** * Service to retrieve and modify the current pen size. diff --git a/src/js/utils/PixelUtils.js b/src/js/utils/PixelUtils.js index 776a587f..d95b0325 100644 --- a/src/js/utils/PixelUtils.js +++ b/src/js/utils/PixelUtils.js @@ -76,7 +76,7 @@ * * @param {Number} row x-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]]) */ resizePixel : function (col, row, size) { @@ -84,11 +84,9 @@ var i; var j; - if (size > 1000000) { size = 1000000; } - for (j = 0; j < size; j++) { 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]); } } diff --git a/test/js/service/pensize/PenSizeServiceTest.js b/test/js/service/pensize/PenSizeServiceTest.js index 3fd48c13..a95daf30 100644 --- a/test/js/service/pensize/PenSizeServiceTest.js +++ b/test/js/service/pensize/PenSizeServiceTest.js @@ -56,7 +56,7 @@ describe("PenSize test suite", function() { penSizeService.init(); // MAX_VALUE is 4 - penSizeService.setPenSize(5); + penSizeService.setPenSize(33); expect(penSizeService.getPenSize()).toBe(1); // MIN_VALUE is 1 penSizeService.setPenSize(0); @@ -70,4 +70,4 @@ describe("PenSize test suite", function() { // no event fired expect($.publish.calls.any()).toBe(false); }); -}); \ No newline at end of file +});