From 70420313ac3569f1b287dcf642b85c08f69b2140 Mon Sep 17 00:00:00 2001 From: Kristian Matthews-Kennington Date: Sun, 30 Jul 2023 00:18:45 +0100 Subject: [PATCH 1/3] Add stroke colour --- Readme.md | 5 +++++ changelog.txt | 3 +++ src/pattern.js | 4 ++-- src/trianglify.js | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 7e61433c..d0af1125 100644 --- a/Readme.md +++ b/Readme.md @@ -197,6 +197,7 @@ const defaultOptions = { colorSpace: 'lab', colorFunction: trianglify.colorFunctions.interpolateLinear(0.5), strokeWidth: 0, + strokeColor: false, points: null } ``` @@ -255,6 +256,10 @@ Boolean, defaults to `true`. Specifies whether the polygons generated by Triangl Number, defaults to 0. Specify the width of the strokes used to outline the polygons. This can be used in conjunction with `fill: false` to generate weblike patterns. +**`strokeColor`** + +False, or string of CSS-formatted colors, default is `false`. + **`points`** Array of points ([x, y]) to triangulate, defaults to null. When not specified an array randomised points is generated filling the space. Points must be within the coordinate space defined by `width` and `height`. See [`examples/custom-points-example.html`](./examples/custom-points-example.html) for a demonstration of how this option can be used to generate circular trianglify patterns. diff --git a/changelog.txt b/changelog.txt index 6f5ab434..71833750 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +v4.2 +- support for stroke color + v4 - ground-up port to ES2015 - support for node-canvas 2.6 diff --git a/src/pattern.js b/src/pattern.js index c9a65efc..2db4b4cf 100644 --- a/src/pattern.js +++ b/src/pattern.js @@ -60,7 +60,7 @@ export default class Pattern { return s('path', { d, fill: opts.fill ? poly.color.css() : undefined, - stroke: hasStroke ? poly.color.css() : undefined, + stroke: hasStroke ? opts.strokeColor || optspoly.color.css() : undefined, 'stroke-width': hasStroke ? opts.strokeWidth : undefined, 'stroke-linejoin': hasStroke ? 'round' : undefined, 'shape-rendering': opts.fill ? 'crispEdges' : undefined @@ -154,7 +154,7 @@ export default class Pattern { polys.forEach(poly => drawPoly( poly, opts.fill && { color: poly.color }, - (opts.strokeWidth > 0) && { color: poly.color, width: opts.strokeWidth } + (opts.strokeWidth > 0) && { color: opts.strokeColor || poly.color, width: opts.strokeWidth } )) return canvas diff --git a/src/trianglify.js b/src/trianglify.js index 38ce19ab..de830205 100644 --- a/src/trianglify.js +++ b/src/trianglify.js @@ -29,6 +29,7 @@ const defaultOptions = { colorFunction: colorFunctions.interpolateLinear(0.5), fill: true, strokeWidth: 0, + strokeColor: false, points: null } From 0e88508e2694e486d9d7cf3c843d90e167894b16 Mon Sep 17 00:00:00 2001 From: Kristian Matthews-Kennington Date: Sun, 14 Jul 2024 19:57:43 +0100 Subject: [PATCH 2/3] chore: Update strokeColor default value to null in trianglify.js --- Readme.md | 4 ++-- src/trianglify.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index d0af1125..c64e3e1d 100644 --- a/Readme.md +++ b/Readme.md @@ -197,7 +197,7 @@ const defaultOptions = { colorSpace: 'lab', colorFunction: trianglify.colorFunctions.interpolateLinear(0.5), strokeWidth: 0, - strokeColor: false, + strokeColor: null, points: null } ``` @@ -258,7 +258,7 @@ Number, defaults to 0. Specify the width of the strokes used to outline the poly **`strokeColor`** -False, or string of CSS-formatted colors, default is `false`. +Null, or string of CSS-formatted colors, default is `false`. **`points`** diff --git a/src/trianglify.js b/src/trianglify.js index de830205..c910e9e1 100644 --- a/src/trianglify.js +++ b/src/trianglify.js @@ -29,7 +29,7 @@ const defaultOptions = { colorFunction: colorFunctions.interpolateLinear(0.5), fill: true, strokeWidth: 0, - strokeColor: false, + strokeColor: null, points: null } From b7458d77f6f9622552ad48ead19f547b1f0f95fa Mon Sep 17 00:00:00 2001 From: Kristian Matthews-Kennington Date: Wed, 17 Jul 2024 19:47:42 +0100 Subject: [PATCH 3/3] Update strokeColor default value to null --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index c64e3e1d..938ca494 100644 --- a/Readme.md +++ b/Readme.md @@ -258,7 +258,7 @@ Number, defaults to 0. Specify the width of the strokes used to outline the poly **`strokeColor`** -Null, or string of CSS-formatted colors, default is `false`. +Null, or string of CSS-formatted colors, default is `null`. **`points`**