/* Copyright (c) 2010 the authors listed at the following URL, and/orthe authors of referenced articles or incorporated external code:http://en.literateprograms.org/RGB_to_HSV_color_space_conversion_(C)?action=history&offset=20060515030319Permission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:The above copyright notice and this permission notice shall beincluded in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANYCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THESOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.Retrieved from: http://en.literateprograms.org/RGB_to_HSV_color_space_conversion_(C)?oldid=4766*/#include <stdlib.h>#include <stdio.h>#include <math.h>#define RED 0.0#define YELLOW 60.0#define GREEN 120.0#define CYAN 180.0#define BLUE 240.0#define MAGENTA 300.0#define MIN3(x,y,z) ((y) <= (z) ? \ ((x) <= (y) ? (x) : (y)) \ : \ ((x) <= (z) ? (x) : (z)))#define MAX3(x,y,z) ((y) >= (z) ? \ ((x) >= (y) ? (x) : (y)) \ : \ ((x) >= (z) ? (x) : (z)))typedef struct { double r, g, b, a; /* Channel intensities between 0.0 and 1.0 */} RGBAColor;typedef struct { double h; /* Hue degree between 0.0 and 360.0 */ double s; /* Saturation between 0.0 (gray) and 1.0 */ double v; /* Value between 0.0 (black) and 1.0 */ double a;} HSVAColor;HSVAColor rgba_to_hsva(RGBAColor);RGBAColor hsva_to_rgba(HSVAColor);