MikeHeuss.com - The eclectic repository of my life. Programming, writing, and other stuff.

HSV Functions

The HSV model of color simplifies the application of color theory. The RGB model, however, is what your web browser uses. I wrote these functions to handle those conversions

They are:

array convertHSVtoRGB($arg_hsv)

When passed an array with three elements: h, s and v, it will return a named array with three elements, r, g and b.

array convertRGBtoHSV($arg_rgb)

When passed an array with three elements: r, g and b, it will return a named array with three elements: h, s, and v.

string convertHSVtoRGBString($arg_hue, $arg_saturation, $arg_brightness)

When passed hue, saturation and brightness, it will return a RGB String, such as FFFFFF. To see an example of this function in use, click here

The HSV class offers these same functions, however, it provides a convenient data container to more advanced and persistant manipulations. The documentation for that class and the above functions can be found here.

To download the source, click here for the tgz file, and here for the zip.

This class is released under the BSD license. Click Here to view.

Last Updated: 5 Sept. 2005

Thanks to Sneaky for spotting a potential issue in the code. This has now been updated to prevent a divide by zero error when working with white.

© 1998 - 2019 Mike Heuss   |   mike@mikeheuss.com  |  386 418 0075  |  6823 NW 218th Street Alachua FL 32615