Changing webcam-pixels to "nearest" color from color palette array

Super cool @kll, thanks for the example :smiley:

I do not have a specific color rule yet, but was thinking about using closest hue, however I have limited experience with this, so any suggestions for the best rule is very welcome? For the project I am facing a webcam towards a perler bead, if that makes sense…

Also, if instead of the web-safe colors, what if I was trying to match a predefined color palette like color[] myColors = {#FF0000, #FFC000, #E0FF00};, any hints how to achieve that?