diff --git a/Readme.md b/Readme.md index 7e61433c..938ca494 100644 --- a/Readme.md +++ b/Readme.md @@ -197,6 +197,7 @@ const defaultOptions = { colorSpace: 'lab', colorFunction: trianglify.colorFunctions.interpolateLinear(0.5), strokeWidth: 0, + strokeColor: null, 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`** + +Null, or string of CSS-formatted colors, default is `null`. + **`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..c910e9e1 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: null, points: null }