HSV value of a color

Miscellaneous Forums/General Discussion/HSV value of a color

Well, that's one way of doing it. But you can do the same with rgb by selecting the color with the least variation.
variation_best = 100000
index_best = 0

For index = 0 Until palette_size
	variation_r = Abs(r - palette_r[index])
	variation_g = Abs(g - palette_g[index])
	variation_b = Abs(b - palette_b[index])
	variation_max = Max(variation_r,Max(variation_g,variation_b))
	If variation_max < variation_best
		index_best = index
		variation_best = variation_max
	EndIf
Next