From 0f5501bc3b512fbc158cb1aeee48ae6117cd04c1 Mon Sep 17 00:00:00 2001 From: Jeff Wofford Date: Tue, 5 May 2020 18:09:35 -0500 Subject: [PATCH] Add outliner tool. --- misc/proto-ui-1/img/outliner-icon-dark.png | Bin 0 -> 4104 bytes misc/proto-ui-1/img/outliner-icon.png | Bin 0 -> 1189 bytes misc/proto-ui-1/main.css | 1 + src/css/dialogs-cheatsheet.css | 4 ++ src/css/tools.css | 1 + src/js/controller/ToolController.js | 3 +- src/js/service/keyboard/Shortcuts.js | 3 +- src/js/tools/drawing/Outliner.js | 39 +++++++++++ src/js/utils/PixelUtils.js | 73 ++++++++++++++++++++- src/piskel-script-list.js | 1 + 10 files changed, 120 insertions(+), 5 deletions(-) create mode 100644 misc/proto-ui-1/img/outliner-icon-dark.png create mode 100644 misc/proto-ui-1/img/outliner-icon.png create mode 100644 src/js/tools/drawing/Outliner.js diff --git a/misc/proto-ui-1/img/outliner-icon-dark.png b/misc/proto-ui-1/img/outliner-icon-dark.png new file mode 100644 index 0000000000000000000000000000000000000000..b6bd648bcc9985b0c1996c04d403a075aa8f5c70 GIT binary patch literal 4104 zcmZ8kc{mhY)Soe98QI40+KnuOtYZr?S;iJ4iIR0hDzaqHHg*$}B}ru|Q5Z|}rm-_4 z2EByHC=61T$d)W2^G)CL{q^1FId^~Vx%WBe_dDm_b+EVM{L%8bd;?uY>^rX!*YaG`Zg6#F`Wfw{Qu+80;4w%Gl|ajPr? zLanEjMoY<(B5Zt!5&4l^JBB?x6_FM$ZYE&@+oSYWHc=E$jEAGYKA<+tF|)T^ag-A+Eqr(0CUe4YwPH!XHWVdW+J+U4X zBTl~%tp(fH=>epqq*&=^hjrkOF3sOlwDMyUEaen{B75Udg#&>Bx3_@yz=T_b?}57} zPi(G2vC+}{%b_iCCqmq1d0$#tStX-oO;AsnUqf5k3wB{}LnFbSY{2ih<1pD!53{e2 zZN;L+KdH-3IY+eNZ)p?`w1u`z?-2b3f7HmynW}=mZU1gSe}iwm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XuR+M*3>rkW|ZeE5!W!@)(kJ0UcJLjGv{#kBObu;5hHrES$$ebbAXm$-%>F-H%|$hf=i173<|5^itWHdhGab~h|NP atLeastOneNeighborHasNonTargetColor(pixel)); + + var paintedPixels = []; + + for (var pixel of pixels) { + frame.setPixel(pixel.col, pixel.row, replacementColor); + paintedPixels.push(pixel); + } + + return paintedPixels; + }, + /** * Starting from a provided origin, visit connected pixels using a visitor function. * After visiting a pixel, select the 4 connected pixels (up, right, down, left). @@ -167,9 +237,6 @@ * @return {Array} the array of visited pixels {col, row} */ visitConnectedPixels : function (pixel, frame, pixelVisitor) { - var col = pixel.col; - var row = pixel.row; - var queue = []; var visitedPixels = []; var dy = [-1, 0, 1, 0]; diff --git a/src/piskel-script-list.js b/src/piskel-script-list.js index 11352a03..4f40630f 100644 --- a/src/piskel-script-list.js +++ b/src/piskel-script-list.js @@ -225,6 +225,7 @@ "js/tools/drawing/Eraser.js", "js/tools/drawing/Stroke.js", "js/tools/drawing/PaintBucket.js", + "js/tools/drawing/Outliner.js", "js/tools/drawing/Rectangle.js", "js/tools/drawing/Circle.js", "js/tools/drawing/Move.js",