Open backhand opened 8 years ago
@backhand sorry for taking such an extraordinarily long time to respond.
Hue should be an int between 0 and 360. The hue represents a degree around the color wheel. You can see a live version here: http://paletton.com/#uid=1000u0kllllaFw0g0qFqFg0w0aF
It seems like this is a problem with floating point imprecision in js. If you try this:
/*jslint node:true, multistr: true */
'use strict';
var ColorScheme = require('color-scheme');
for(let hue = 0; hue < 256; hue++) {
for(let dist = 0.0; dist < 1.0; dist+=0.01) {
try {
let scheme = new ColorScheme();
scheme.from_hue(hue)
.scheme('triade')
.variation('hard')
.distance(dist);
let colors = scheme.colors();
console.log(colors[0]);
} catch(err) {
console.log(hue, dist, err);
}
}
}
You'll see that there are only errors for certain colors, not all.
And if you modify dist like this dist = dist.toFixed(2);
it seems like the problem goes away.
The solution may be to just clamp distances to 2 floating points (or somewhere around there) in the library.
Hi,
I'm assuming that hue should be an int between 0-255 and distance a float between 0 and 1. Given that, I've experienced the following error with various combinations of hue and distance:
hue 170 and distance 0.16 will throw this error. This will list out some of the values:
Did I misunderstand something in the use of your library?