Skip to content

Commit

Permalink
Small distance adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
tristen committed Feb 5, 2021
1 parent 04fd11a commit 9d90445
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class toColor {
const b = this._pickBrightness(h, s);
const hsl = this._HSVtoHSL(h, s, b);
const formatted = this._formatHSL(hsl);
const PASSABLE_DISTANCE = 50;
const PASSABLE_DISTANCE = 60;

// The larger `count` grows, we need to divide actual distance to avoid
// hitting a maxiumum call stack error.
Expand All @@ -34,9 +34,9 @@ export default class toColor {
return this.getColor(count);
} else {
this.known.push(formatted);
// Apply modifiers after distribution check + regeneration to ensure
// Apply modifiers after distribution check + regeneration to ensure
// colors with brightness/saturation adjustments remain the same.
return this._colorWithModifiers(h, s, b)
return this._colorWithModifiers(h, s, b)
}
}

Expand All @@ -59,7 +59,7 @@ export default class toColor {
}
};
}

_formatHSL = hsl => `hsl(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%)`

_pickHue = () => {
Expand All @@ -82,7 +82,7 @@ export default class toColor {
let max = saturationRange[1];
return this._pseudoRandom([min, max]);
}


_pickBrightness = (h, s) => {
let min = this._getMinimumBrightness(h, s);
Expand Down
8 changes: 4 additions & 4 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ describe('toColor', () => {
it('returns a different determinisic value calling getColor again', () => {
expect(color.getColor()).toEqual({
hsl: {
formatted: 'hsl(14, 16.95%, 38.04%)',
raw: [14, 16.95, 38.04]
formatted: 'hsl(347, 17.64%, 34.85%)',
raw: [347, 17.64, 34.85]
}
});
});
Expand All @@ -77,8 +77,8 @@ describe('toColor', () => {
}
expect(finalValue).toEqual({
hsl: {
formatted: 'hsl(277, 48.97%, 50.99%)',
raw: [277, 48.97, 50.99]
formatted: 'hsl(7, 61.34%, 61.2%)',
raw: [7, 61.34, 61.2]
}
});
});
Expand Down

0 comments on commit 9d90445

Please sign in to comment.