From rgb to xterm256#13
Conversation
|
Thank you for your contribution. But, I cannot merge this now because I still consider that how to find the closest color. I guess that one candidate is LUV color space with the appropriate reference white point. I need more time for studying color theory to decide the appropriate method. |
|
Hello @mrkn , thank you for the consideration. I based the xterm256 approximation on the algorithm found in Per the description below, the xterm256 color palette is extremely coarse. Because of that, I was hoping that it would be close enough: |
|
I know tmux uses RGB color space to determine the closest color, and I don't want to follow tmux. In unicode_plot, I would like to derive the closest color using a distance space where the distance between two colors that the human eye perceives as close is small. I guess CIELUV colorspace is more appropriate than the other color spaces. |
Hello @mrkn , I needed some methods for converting an rgb value into the closest xterm256 color - this package previously only contained the methods for xterm256->to_rgb. I added support as a class method: Colors::Xterm256.from_rgb(rgb), but can move to an instance method on Colors::RGB (e.g. Colors::RGB#to_xterm256) if that is more appropriate.
I plan to use the two way conversion in unicode_plot.rb.