How do I take r,g,b values and compare them to a websafe color palette to find the best match for the r,g,b value?
There's this one: What is the best algorithm for finding the closest color in an array to another color?
But I don't think it's what I need. I just need to compare an r,g,b with a websafe color and find out if the websafe color is the best choice.
Edit1: deleted
Edit2: This is what I have so far.
local r, g, b = HSV2RGB(h, s, v)
local dither = copy(WEB_SAFE)
local lmod
for i, v in ipairs(dither) do
local r2, g2, b2 = Color2RGBA(v)
local hh, ss, vv = RGB2HSV(r2, g2, b2)
local a = hh - h
local b = ss - s
local c = vv - v
local mod = a*a + b*b + c*c
if not lmod or mod < lmod then
lmod = mod
r, g, b = r2, g2,b2
end
end
texture:SetBackgroundColor(r, g, b)
Edit 3: Is this what it's supposed to look like?
h=1 through 360 at 5 pt steps, s=1 through 100, v = 89