From aca6c28b4b002544d47d1435b6c01339ee7dfc47 Mon Sep 17 00:00:00 2001 From: Smie Date: Fri, 28 Oct 2016 17:56:22 -0600 Subject: [PATCH] Allows square brush size of up to 1,000,000 pixels using keyboard shortcuts. --- src/js/service/pensize/PenSizeService.js | 2 +- src/js/utils/PixelUtils.js | 33 +++++++----------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/js/service/pensize/PenSizeService.js b/src/js/service/pensize/PenSizeService.js index 5866cff2..d2b3fbc1 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 = 4; + var MAX_PENSIZE = 1000000; /** * Service to retrieve and modify the current pen size. diff --git a/src/js/utils/PixelUtils.js b/src/js/utils/PixelUtils.js index 667d7a48..9efd461c 100644 --- a/src/js/utils/PixelUtils.js +++ b/src/js/utils/PixelUtils.js @@ -76,33 +76,20 @@ * * @param {Number} row x-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]]) */ resizePixel : function (col, row, size) { - if (size == 1) { - return [[col, row]]; - } else if (size == 2) { - return [ - [col, row], [col + 1, row], - [col, row + 1], [col + 1, row + 1] - ]; - } 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); + var pixels = []; + 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]); + } } + + return pixels; }, /**