#pragma once #include "Vector.h" #include "AftrOpenGLIncludes.h" namespace Aftr { /// Link to HSV Color space illustration: /// https://en.wikipedia.org/wiki/HSL_and_HSV /// https://en.wikipedia.org/wiki/HSL_and_HSV#/media/File:Hsl-hsv_models.svg /// Converts a Hue, Saturation, Value Color to Red, Green, Blue. /// Assumes all color values are floating point values in the range [0,1] /// Input: hsv.x -> hue, hsv.y -> saturation, hsv.z = value /// Return .x -> red, .y -> green, .z -> blue /// /// Hue is a value [0,1] that maps to [0,360) degrees. /// Saturation is how intense the color is. 1 is "full" color, 0 is all while, 0.5 is "washed out / faded" /// Value is how bright the color is. 1 is full brightness, 0 is black, 0.5 is half way. /// 0.0000 (0 deg) --> Red /// 0.1667 (60 deg) --> Yellow /// 0.3333 (120 deg) --> Green /// 0.5000 (180 deg) --> Cyan /// 0.6667 (240 deg) --> Blue /// 0.8333 (300 deg) --> Magenta /// 1.0 (360 deg) --> Red /// If I wanted to create a Red Color and linearly interpolate it to across HSV, I would do: /// Vector hsv_startColor{0,1,1}; //this is red /// Vector hsv_endColor{0.8333,1,1}; //this is magenta template< typename T > VectorT convertHSVtoRGB( VectorT const& hsv ); template< typename T > Aftr::VectorT convertRGBtoHSV( VectorT const& rgb ); /// Simple utility method that takes a 4 channel rgba, chops off the .a /// and returns the RGB inside the XYZ of a Vector, respectively. Vector make_vec_from_color( aftrColor4ub const& c ); /// Simple utility method that takes a 4 channel rgba, chops off the .a /// and returns the RGB inside the XYZ of a Vector, respectively. Vector make_vec_from_color( aftrColor4f const& c ); std::string to_string( aftrColor4ub const& c ); } //namespace Aftr