0

Is it possible to round hex colors to previously set hex colors? Like I would put colors in an array and round other colors to the closest color in that array.

If it's possible, how would I implement that?

pr -
  • 240
  • 2
  • 9
  • What does "previously set hex colors" mean? – Pointy Mar 24 '21 at 19:21
  • I would specify a list of colors in an array – pr - Mar 24 '21 at 19:22
  • Convert the hexadecimal string to a number (if it isn't already), [round it to the nearest value in your array](https://stackoverflow.com/questions/8584902/get-the-closest-number-out-of-an-array), then convert it back to a hexadecimal string. – Ivar Mar 24 '21 at 19:25
  • @Ivar Will hex colors work? – pr - Mar 24 '21 at 19:32
  • @pineapplerind0215 Checkout [this answer](https://stackoverflow.com/a/8575671/479156). – Ivar Mar 24 '21 at 19:52

0 Answers0