-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Color Map #49
Comments
function get_closest(hex) {
let color = hex.toUpperCase();
let minDistance = Number.MAX_SAFE_INTEGER;
let closestColorName = '';
for (let c in colors) {
let distance = getDistance(color, c);
if (distance < minDistance) {
minDistance = distance;
closestColorName = colors[c];
}
}
return closestColorName;
}
function getDistance(c1, c2) {
let r1 = parseInt(c1.substr(0, 2), 16);
let g1 = parseInt(c1.substr(2, 2), 16);
let b1 = parseInt(c1.substr(4, 2), 16);
let r2 = parseInt(c2.substr(0, 2), 16);
let g2 = parseInt(c2.substr(2, 2), 16);
let b2 = parseInt(c2.substr(4, 2), 16);
let dr = r1 - r2;
let dg = g1 - g2;
let db = b1 - b2;
return Math.sqrt(dr * dr + dg * dg + db * db);
}
let closest = get_closest('ADF0FE'); |
This review doesn't even mention color names, lol. https://youtu.be/k0OhVtxJHMA?t=365 When I saw that I was like, why do I need to to connect chatGPT for a color grabber?? 😂 |
ChatGPT doesn't know 16M color names, it knows 480, well that's all I could get out of it by asking e.g. what color names are between eggshell and pearl. Tearing through your API allowance 10 times a second, is horrific. |
Wouldn't this be a lot more efficient, it's more colors that ChatGPT knows.
The text was updated successfully, but these errors were encountered: