Gray color with hex shorthand between #fff and #eee

Thanks for the tips, everyone.

Below is my algorithm (in JavaScript) that takes a given RGB code and finds the closest RGB color code, that can be represented in shorthand hex code:

var red, green, blue;
var redClosest = Math.round(red / 17) * 17;
var greenClosest = Math.round(green / 17) * 17;
var blueClosest = Math.round(blue / 17) * 17;

I don’t think anyone else might ever need this, but putting here just in case.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.