RGB to HSV & HSV to RGB Color Conversions


Rainbows seem to be pretty popular lately, so I thought I’d share this.

While working on a graphics assignment for school, I decided I wanted my lights to cycle through the full spectrum of colors. The problem was doing so while using RGB, since the loop can get a bit messy to achieve the effect. That’s when I decided to make an RGB to HSV converter, as well as an HSV to RGB converter. For those of you who don’t know, RGB and HSV are just two different ways of representing a color as a collection of three numbers. RGB stands for Red Channel, Green Channel and Blue Channel, while HSV stands for Hue, Saturation and Brightness (V is used instead of B to avoid confusion with Blue). Below is my implementation, which is the classical one with a slight performance increase trick that I found. I will provide all the links to my resources below.

Read More