Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
John Merchant committed Jul 13, 2019
1 parent 5a6ecae commit 2114934
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ var names = namer(color, { omit: ['pantone', 'roygbiv'] })
// output: { basic: [...], html: [...], x11: [...], ntc: [...] }
```

### options.distance
If 'deltaE', use the [Delta-E](http://zschuessler.github.io/DeltaE/learn/) distance function, otherwise uses default distance function.

```js
var names = namer(color, { pick: ['basic'], distance: 'deltaE' });
// output: { basic: [...] }
```

###

## Tests

```
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var namer = module.exports = function(color, options) {
return cache.get(cacheKey)
}

var deltaE = String(options.distance).toLowerCase() === 'deltae';
color = chroma(color)
var results = {}
for (var key in lists) {
Expand All @@ -34,7 +35,7 @@ var namer = module.exports = function(color, options) {
}
results[key] = lists[key]
.map (function(name) {
name.distance = options.distance === 'deltaE' ? chroma.deltaE(color, chroma(name.hex)) : chroma.distance(color, chroma(name.hex))
name.distance = deltaE ? chroma.deltaE(color, chroma(name.hex)) : chroma.distance(color, chroma(name.hex))
return name
})
.sort (function(a, b) {
Expand Down

0 comments on commit 2114934

Please sign in to comment.