Comments (3)
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');
from colorgpt.
Because there's 16 million possible colors to name. Even if you count the fact that some of them have the same color, you still have to build through a database that big and search through it.
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.
The code above gets the closest color name to any of the 16M hex codes. There's 550 colors in the list.
Tearing through your API allowance 10 times a second, is horrific.
from colorgpt.
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?? 😂
from colorgpt.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from colorgpt.