From 2b840c2f477a2908375a9e7c9038b97578c07a50 Mon Sep 17 00:00:00 2001 From: DD Date: Tue, 3 Apr 2018 18:21:12 -0400 Subject: [PATCH 1/8] Add ability to fill transparent text --- src/helper/tools/fill-tool.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/helper/tools/fill-tool.js b/src/helper/tools/fill-tool.js index 572c6a23..5c99d68f 100644 --- a/src/helper/tools/fill-tool.js +++ b/src/helper/tools/fill-tool.js @@ -44,8 +44,13 @@ class FillTool extends paper.Tool { fill: true, guide: false, match: function (hitResult) { - return (hitResult.item instanceof paper.Path || hitResult.item instanceof paper.PointText) && - (hitResult.item.hasFill() || hitResult.item.closed || isAlmostClosedPath(hitResult.item)); + if (hitResult.item instanceof paper.Path && + (hitResult.item.hasFill() || hitResult.item.closed || isAlmostClosedPath(hitResult.item))) { + return true; + } + if (hitResult.item instanceof paper.PointText) { + return true; + } }, hitUnfilledPaths: true, tolerance: FillTool.TOLERANCE / paper.view.zoom From e64f015489622feb095302d6e8425a7da1e2ad35 Mon Sep 17 00:00:00 2001 From: Jacco Kulman Date: Sat, 7 Apr 2018 07:59:52 +0200 Subject: [PATCH 2/8] Replace png background with vector version --- src/helper/background.png | Bin 47450 -> 0 bytes src/helper/layer.js | 48 +++++++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 11 deletions(-) delete mode 100644 src/helper/background.png diff --git a/src/helper/background.png b/src/helper/background.png deleted file mode 100644 index 74902b2ada12ee23b52c754523af3d42c4cebca5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 47450 zcmeI5&r4KM6vyvmLR!`)TSyY*s;Gr6BCxRW2aZr8V$duKrKC1tC8v$}sm@Hi-Tx(cv;9i?Y}%N~2Rj!# zi-Y$i*E883V|Ks%`$)}nk6$)s>PK@!y1oD6w|sS(sWwHE3!nd-cro{;K0Q63dj06< zsilFvhuU(P(SwbH>MxFe*Z3ViSsmGTbhBLSTqZwNrQmd4S$(Pz)Lru<3aP{^s{@A> z!gy@B2CGgvIac`$0=i9EI<)T{cj`Bmbn6xBbczW8>lg`2SO>6T1+a4C1Qe`T?z8m>04#tNb20!cm;1s;vb2c9*Ts_F;(Qqe zE0zx|SH&x=16Tkn7Ek~dz*>^()u80iIjbmo7X$ z@+AGPe6YYJIs}=^HuC&CXO}RVXsUqiuH2xyV;TFvN7Al#El#RPzLTfk&Sm9P$A z9fL@zm;kU&3z(oN(ZM=^1+d{Yb(}g`2|7OMW&jIdAg01IFN zY@C#(gLME4VB>h}njz@w0hB0Mx!h-2VE_wY<(y0hIzCwiumBdoqF@UTz?9~aK5eaH z23yz#U6B4V3Ub;{!J&LSVzGovzVYooXlbZzyjDf{T8$&E#hz=SUdRI$ajP%zuDWp zXNt_O>C;2CU%PJ|8|pu4vJro*(lNf=zdPdfiCs){@?M45up$M=(n$OW(wvRasLMqJ-q2Ee*L15XJ$ z++H-K#F9){UZD=ax~`veP^V*+v*Qzrbrh^)9imiBY>KnvU1#8x(W_Tjr$y}AsQ_$3 zQAdk7nW)pz%>Xu;Y8}7=Sh+2IUNvh0EPxeD9$f$yz{*W}bX1*3R_FSDn^#xMvxDb5 St_8OXG|i1I4HI=8cb5S;XkpF( diff --git a/src/helper/layer.js b/src/helper/layer.js index 61473824..941121de 100644 --- a/src/helper/layer.js +++ b/src/helper/layer.js @@ -1,5 +1,4 @@ import paper from '@scratch/paper'; -import canvasBg from './background.png'; import log from '../log/log'; const _getLayer = function (layerString) { @@ -72,19 +71,46 @@ const _makePaintingLayer = function () { return paintingLayer; }; +const _makeBackgroundPaper = function (width, height, color) { + var x = 0; + var y = 0; + var sb = []; + while (x < width) { + sb.push(new paper.Point(x,y)); + x++; + sb.push(new paper.Point(x,y)); + y = y == 0 ? height : 0; + } + y = height - 1; + x = width; + while (y > 0) { + sb.push(new paper.Point(x,y)); + x = (x == 0 ? width : 0); + sb.push(new paper.Point(x,y)); + y--; + } + const vRect = new paper.Shape.Rectangle(new paper.Point(0,0), new paper.Point(120,90)); + vRect.fillColor = '#fff'; + vRect.guide = true; + vRect.locked = true; + const vPath = new paper.Path(sb); + vPath.fillRule = 'evenodd'; + vPath.fillColor = color; + vPath.guide = true; + vPath.locked = true; + const vGroup = new paper.Group([vRect, vPath]); + return vGroup; +} + const _makeBackgroundGuideLayer = function () { const guideLayer = new paper.Layer(); guideLayer.locked = true; - const img = new Image(); - img.src = canvasBg; - img.onload = () => { - const raster = new paper.Raster(img); - raster.parent = guideLayer; - raster.guide = true; - raster.locked = true; - raster.position = paper.view.center; - raster.sendToBack(); - }; + + const vBackground = _makeBackgroundPaper(120, 90, '#E5E5E5'); + vBackground.position = paper.view.center; + vBackground.scaling = new paper.Point(4,4); + vBackground.guide = true; + vBackground.locked = true; const vLine = new paper.Path.Line(new paper.Point(0, -7), new paper.Point(0, 7)); vLine.strokeWidth = 2; From b7f0551facd7b2ef8a4120f275c04bd3afd67065 Mon Sep 17 00:00:00 2001 From: Jacco Kulman Date: Sat, 7 Apr 2018 08:20:59 +0200 Subject: [PATCH 3/8] Fixes (whitespace, semicolons) to satisfy TRAVIS --- src/helper/layer.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/helper/layer.js b/src/helper/layer.js index 941121de..6c080bbb 100644 --- a/src/helper/layer.js +++ b/src/helper/layer.js @@ -72,35 +72,35 @@ const _makePaintingLayer = function () { }; const _makeBackgroundPaper = function (width, height, color) { - var x = 0; - var y = 0; - var sb = []; + let x = 0; + let y = 0; + let pathPoints = []; while (x < width) { - sb.push(new paper.Point(x,y)); + pathPoints.push(new paper.Point(x, y)); x++; - sb.push(new paper.Point(x,y)); - y = y == 0 ? height : 0; + pathPoints.push(new paper.Point(x, y)); + y = y === 0 ? height : 0; } y = height - 1; x = width; while (y > 0) { - sb.push(new paper.Point(x,y)); - x = (x == 0 ? width : 0); - sb.push(new paper.Point(x,y)); + pathPoints.push(new paper.Point(x, y)); + x = (x === 0 ? width : 0); + pathPoints.push(new paper.Point(x, y)); y--; } - const vRect = new paper.Shape.Rectangle(new paper.Point(0,0), new paper.Point(120,90)); + const vRect = new paper.Shape.Rectangle(new paper.Point(0, 0), new paper.Point(120, 90)); vRect.fillColor = '#fff'; vRect.guide = true; vRect.locked = true; - const vPath = new paper.Path(sb); + const vPath = new paper.Path(pathPoints); vPath.fillRule = 'evenodd'; vPath.fillColor = color; vPath.guide = true; vPath.locked = true; const vGroup = new paper.Group([vRect, vPath]); return vGroup; -} +}; const _makeBackgroundGuideLayer = function () { const guideLayer = new paper.Layer(); @@ -108,7 +108,7 @@ const _makeBackgroundGuideLayer = function () { const vBackground = _makeBackgroundPaper(120, 90, '#E5E5E5'); vBackground.position = paper.view.center; - vBackground.scaling = new paper.Point(4,4); + vBackground.scaling = new paper.Point(4, 4); vBackground.guide = true; vBackground.locked = true; From d0536be3aea85f5efb0526a8e7954b288c0fef1d Mon Sep 17 00:00:00 2001 From: Jacco Kulman Date: Sat, 7 Apr 2018 08:25:33 +0200 Subject: [PATCH 4/8] Fixes (const instead of let) to satisfy TRAVIS --- src/helper/layer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/layer.js b/src/helper/layer.js index 6c080bbb..29cb2394 100644 --- a/src/helper/layer.js +++ b/src/helper/layer.js @@ -74,7 +74,7 @@ const _makePaintingLayer = function () { const _makeBackgroundPaper = function (width, height, color) { let x = 0; let y = 0; - let pathPoints = []; + const pathPoints = []; while (x < width) { pathPoints.push(new paper.Point(x, y)); x++; From 0753b7ccc11a0d128c059365a0adf4a6da39c0b1 Mon Sep 17 00:00:00 2001 From: Jacco Kulman Date: Sat, 7 Apr 2018 08:42:32 +0200 Subject: [PATCH 5/8] Added a comment (TRAVIS took wrong version) --- src/helper/layer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/helper/layer.js b/src/helper/layer.js index 29cb2394..677dbae0 100644 --- a/src/helper/layer.js +++ b/src/helper/layer.js @@ -72,6 +72,7 @@ const _makePaintingLayer = function () { }; const _makeBackgroundPaper = function (width, height, color) { + // creates a checkerboard path of width * height squares in color on white let x = 0; let y = 0; const pathPoints = []; From e5c582f86b5eeb4f7f5cccfa0f3b1fa743b84e5b Mon Sep 17 00:00:00 2001 From: DD Date: Mon, 9 Apr 2018 17:49:39 -0400 Subject: [PATCH 6/8] Make sure to remove the bounding box when no items are selected --- src/helper/selection-tools/bounding-box-tool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helper/selection-tools/bounding-box-tool.js b/src/helper/selection-tools/bounding-box-tool.js index f9035aab..879b8b70 100644 --- a/src/helper/selection-tools/bounding-box-tool.js +++ b/src/helper/selection-tools/bounding-box-tool.js @@ -51,10 +51,10 @@ class BoundingBoxTool { /** * Should be called if the selection changes to update the bounds of the bounding box. - * @param {Array} selectedItems Array of selected items. + * @param {?Array} selectedItems Array of selected items. */ onSelectionChanged (selectedItems) { - if (selectedItems) { + if (selectedItems && selectedItems.length) { this.setSelectionBounds(); } else { this.removeBoundsPath(); From d27aa0f5dd513cceb0654cbb5802e1d673f46e01 Mon Sep 17 00:00:00 2001 From: DD Date: Wed, 11 Apr 2018 14:38:41 -0400 Subject: [PATCH 7/8] Fix test --- test/unit/format-reducer.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unit/format-reducer.test.js b/test/unit/format-reducer.test.js index 42527852..1941aed3 100644 --- a/test/unit/format-reducer.test.js +++ b/test/unit/format-reducer.test.js @@ -22,10 +22,10 @@ test('undoRedoChangeFormat', () => { let defaultState; let reduxState = reducer(defaultState /* state */, changeFormat(Formats.BITMAP) /* action */); expect(reduxState).toBe(Formats.BITMAP); - reduxState = reducer(reduxState /* state */, undo(Formats.UNDO_BITMAP) /* action */); - expect(reduxState).toBe(Formats.UNDO_BITMAP); - reduxState = reducer(reduxState /* state */, redo(Formats.UNDO_VECTOR) /* action */); - expect(reduxState).toBe(Formats.UNDO_VECTOR); + reduxState = reducer(reduxState /* state */, undo(Formats.BITMAP_SKIP_CONVERT) /* action */); + expect(reduxState).toBe(Formats.BITMAP_SKIP_CONVERT); + reduxState = reducer(reduxState /* state */, redo(Formats.VECTOR_SKIP_CONVERT) /* action */); + expect(reduxState).toBe(Formats.VECTOR_SKIP_CONVERT); }); test('invalidChangeMode', () => { From a0d22a09da8d26c76c1f9df61767d2170d0e3a95 Mon Sep 17 00:00:00 2001 From: DD Date: Wed, 11 Apr 2018 14:45:11 -0400 Subject: [PATCH 8/8] Add updated version of Paper --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index acba26ff..0e9985ae 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "react-dom": "^16" }, "devDependencies": { - "@scratch/paper": "0.11.20180329192534", + "@scratch/paper": "0.11.20180411183636", "autoprefixer": "8.1.0", "babel-cli": "6.26.0", "babel-core": "^6.23.1",