diff --git a/fggl/gui/containers.cpp b/fggl/gui/containers.cpp index 60056ec60d76bf95cf2837aab47e6ed27d419e99..ce6f1fc9907b0788bce793075b94ce73e5fb6c72 100644 --- a/fggl/gui/containers.cpp +++ b/fggl/gui/containers.cpp @@ -54,11 +54,9 @@ namespace fggl::gui { }*/ void Panel::render(gfx::Paint &paint) { - spdlog::info("Imma render mah panel! {}, {}", bottomRight().x, bottomRight().y ); - // background painting time gfx::Path2D background(topLeft()); - background.colour(math::vec3(1.0F, 1.0F, 0.0F)); + background.colour(math::vec3(32.0f/255.0f, 74.0F/255.0F, 135.0F/255.0F)); draw_box(background, topLeft(), bottomRight()); paint.fill(background); diff --git a/include/fggl/gui/widget.hpp b/include/fggl/gui/widget.hpp index f740bf1db71c38770819e7aba2831ab4cb3ac812..813cf3953ea3cc7835636024a1f8a302ed6c6ebc 100644 --- a/include/fggl/gui/widget.hpp +++ b/include/fggl/gui/widget.hpp @@ -8,6 +8,43 @@ namespace fggl::gui { + constexpr float RGB_MAX_VAL = 255.0F; + constexpr math::vec3 rgbToNormal(char red, char green, char blue) { + return {red / RGB_MAX_VAL, green / RGB_MAX_VAL, blue / RGB_MAX_VAL}; + } + + /** + * Convert a Hue-saturation-value colour to RGB + * + * @param hue hue component, assumed 0 - 360 + * @param saturation assumed 0 - 1 + * @param value assumed 0 - 1 + * @return RGB, in the range 0,1 for each component + */ + constexpr math::vec3 HSVtoNormal(float hue, float saturation, float value) { + assert( 0 < hue && hue <= 360); + assert( 0 < saturation && saturation <= 1); + assert( 0 < value && value <= 1); + + const float chroma = value * saturation; + const float x = chroma * (1 - fabs( fmod(hue / 60.0F, 2) - 1) ); + math::vec3 tmp{0,0,0}; + if ( 0 <= hue && hue < 60 ) { + tmp = {chroma,x,0}; + } else if ( 60 <= hue && hue < 120 ) { + tmp = {x, chroma, 0}; + } else if (120 <= hue && hue < 180 ) { + tmp = {0, chroma, x}; + } else if ( 180 <= hue && hue < 240 ) { + tmp = {0, x, chroma}; + } else if ( 240 <= hue && hue < 300) { + tmp = {x, 0, chroma}; + } else if ( 300 <= hue && hue < 360) { + tmp = {chroma, 0, x}; + } + return tmp + (value - chroma); + } + void draw_box( gfx::Path2D& path, math::vec2 topLeft, math::vec2 bottomRight); void draw_progress( gfx::Path2D& path, math::vec2 topLeft, math::vec2 size, float value); void draw_slider( gfx::Path2D& path, math::vec2 topLeft, math::vec2 size, float value);