re rgb to hvs and back remco hartog remcoha htsa aha nl wrote i have a little question i need to convert rgb coded red green blue colors into hvs coded hue value saturnation colors does anyone know which formulas to use lets see if i have this right hsv hsb hsl and none of those are the same as hls hopefully hvs is just a transposition of hsv and not yet another color model the following code should do the hsv hsl coding i haven t tried it yet thanks to bultman dgw rws nl another possibility is mirrors msdos graphics graphgem zip on wuarchive wustl edu bill neisius bill solaria hac com the following code is from the starbase hp manual all coordinates noralised at interval hsl to rgb hue saturation luminosity red green blue float hue saturation luminosity input in hsl float red green blue output in rgb float frac lx ly lz temporaries hue hue frac hue int hue lx luminosity saturation ly luminosity saturation frac lz luminosity saturation frac switch int hue case case red luminosity green lz blue lx break case red ly green luminosity blue lx break case red lx green luminosity blue lz break case red lx green ly blue luminosity break case red lz green lx blue luminosity break case red luminosity green lx blue ly break rgb to hsl red green blue hue saturation luminosity define max a b c a b a b c a b a b c define min a b c a b a b c a b a b c float red green blue input in rgb float hue saturation luminosity output in hsl float x tempr tempg tempb temporary values hue saturation luminosity max red green blue x min red green blue if luminosity calculate only if necessary saturation luminosity x luminosity if saturation calculate only if necessary tempr luminosity red luminosity x tempg luminosity green luminosity x tempb luminosity blue luminosity x if red luminosity hue green x tempb tempg else if green luminosity hue blue x tempr tempb else hue red x tempg tempr hue
