From e64f015489622feb095302d6e8425a7da1e2ad35 Mon Sep 17 00:00:00 2001 From: Jacco Kulman Date: Sat, 7 Apr 2018 07:59:52 +0200 Subject: [PATCH 1/4] 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 2/4] 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 3/4] 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 4/4] 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 = [];