diff --git a/examples/qmake/main.cpp b/examples/qmake/main.cpp index 9f3829f..d3a3a53 100644 --- a/examples/qmake/main.cpp +++ b/examples/qmake/main.cpp @@ -11,7 +11,9 @@ int main( int, char* argv[] ) { - tq::ColorTable::load( VIVID_ROOT_PATH "/res/colors.json" ); + using namespace vivid; + + ColorTable::load( VIVID_ROOT_PATH "/res/colors.json" ); QDir dir( argv[ 0 ] ); dir.cdUp(); @@ -20,8 +22,8 @@ int main( int, char* argv[] ) // introduction - tq::ColorMap hslMap( tq::ColorMap::PresetHsl ); - std::cout << tq::ansi::colorize( "vivid", hslMap ) << std::endl; + ColorMap hslMap( ColorMap::PresetHsl ); + std::cout << ansi::colorize( "vivid", hslMap ) << std::endl; std::cout << std::endl; // colormaps @@ -29,23 +31,23 @@ int main( int, char* argv[] ) dir.mkpath( "colormaps/" ); dir.cd( "colormaps/" ); - std::vector defaults = { - tq::ColorMap::PresetBlueYellow, - tq::ColorMap::PresetCoolWarm, - tq::ColorMap::PresetInferno, - tq::ColorMap::PresetMagma, - tq::ColorMap::PresetPlasma, - tq::ColorMap::PresetRainbow, - tq::ColorMap::PresetHsl, - tq::ColorMap::PresetHslPastel, - tq::ColorMap::PresetViridis, - tq::ColorMap::PresetVivid + std::vector defaults = { + ColorMap::PresetBlueYellow, + ColorMap::PresetCoolWarm, + ColorMap::PresetInferno, + ColorMap::PresetMagma, + ColorMap::PresetPlasma, + ColorMap::PresetRainbow, + ColorMap::PresetHsl, + ColorMap::PresetHslPastel, + ColorMap::PresetViridis, + ColorMap::PresetVivid }; for ( const auto& type : defaults ) { - tq::ColorMap cmap( type ); - cmap.interpolation = tq::ColorMap::InterpolationHcl; + ColorMap cmap( type ); + cmap.interpolation = ColorMap::InterpolationHcl; QImage img( 512, 32, QImage::Format_RGB32 ); for ( int c = 0; c < img.width(); c++ ) @@ -59,7 +61,7 @@ int main( int, char* argv[] ) } } - img.save( dir.filePath( QString::fromStdString( tq::ColorMap::nameForPreset( type ) + ".png" ) )); + img.save( dir.filePath( QString::fromStdString( ColorMap::nameForPreset( type ) + ".png" ) )); } // interpolation @@ -68,22 +70,22 @@ int main( int, char* argv[] ) dir.mkdir( "interpolations/" ); dir.cd( "interpolations/" ); - using colorlerp_t = std::function< tq::col_t( const tq::col_t&, const tq::col_t&, const float ) >; + using colorlerp_t = std::function< col_t( const col_t&, const col_t&, const float ) >; using annotated_colorlerp_t = std::pair; - auto lerpHslClamp = []( const tq::col_t& c1, const tq::col_t& c2, const float t ) { - return tq::rgb::clamp( tq::rgb::lerpHsl( c1, c2, t ) ); + auto lerpHslClamp = []( const col_t& c1, const col_t& c2, const float t ) { + return rgb::clamp( rgb::lerpHsl( c1, c2, t ) ); }; const std::vector lerps = { - { tq::rgb::lerp, "lerpRgb" }, - { tq::rgb::lerpHsv, "lerpHsv" }, - { tq::rgb::lerpHsl, "lerpHsl" }, - { tq::rgb::lerpHcl, "lerpHcl" }, + { rgb::lerp, "lerpRgb" }, + { rgb::lerpHsv, "lerpHsv" }, + { rgb::lerpHsl, "lerpHsl" }, + { rgb::lerpHcl, "lerpHcl" }, { lerpHslClamp, "lerpHslClamped" } }; - static const tq::col_t c1( 0.7f, 0.3f, 0.3f ); - static const tq::col_t c2( 0.1f, 0.6f, 0.4f ); + static const col_t c1( 0.7f, 0.3f, 0.3f ); + static const col_t c2( 0.1f, 0.6f, 0.4f ); for ( const auto& lerp: lerps ) { @@ -105,37 +107,37 @@ int main( int, char* argv[] ) // low-level conversions - static const tq::col_t col( 1.f, 0.7f, 0.5f ); - const auto hsl = tq::hsl::fromRgb( col ); - const auto rgb_2 = tq::rgb::fromHsl( hsl ); + static const col_t col( 1.f, 0.7f, 0.5f ); + const auto hsl = hsl::fromRgb( col ); + const auto rgb_2 = rgb::fromHsl( hsl ); std::cout << col << " -> " << hsl << " -> " << rgb_2 << std::endl; // high-level conversions - tq::Color color1, color2; - color1 = tq::Color( c1 ); - color2 = tq::Color( c2 ); + Color color1, color2; + color1 = Color( c1 ); + color2 = Color( c2 ); std::cout << color1.hsl() << std::endl; - std::cout << tq::lerp( color1.hsl(), color2.hsl(), 0.5f ) << std::endl; + std::cout << lerp( color1.hsl(), color2.hsl(), 0.5f ) << std::endl; // encoding - std::cout << tq::ansi::fg( 3 ) << "yay colors" << tq::ansi::reset << std::endl; - std::cout << tq::html::fg( "#abc123" ) << "hex hex!" << tq::html::close << std::endl; - std::cout << tq::html::fg( tq::col8_t( 100, 144, 159 ) ) << "html, aw yes" << tq::html::close << std::endl; + std::cout << ansi::fg( 3 ) << "yay colors" << ansi::reset << std::endl; + std::cout << html::fg( "#abc123" ) << "hex hex!" << html::close << std::endl; + std::cout << html::fg( col8_t( 100, 144, 159 ) ) << "html, aw yes" << html::close << std::endl; std::cout << std::endl; // escape codes - tq::printColorTable(); + printColorTable(); // rainbow text - tq::ColorMap rainbowMap( tq::ColorMap::PresetRainbow ); + ColorMap rainbowMap( ColorMap::PresetRainbow ); const std::string text = "How can you tell? - Raaaaaaiiiinbooooooowwws."; - std::cout << tq::ansi::colorize( text, rainbowMap ) << std::endl; + std::cout << ansi::colorize( text, rainbowMap ) << std::endl; return EXIT_SUCCESS; } diff --git a/include/vivid/color.h b/include/vivid/color.h index 43bf01a..d737e64 100644 --- a/include/vivid/color.h +++ b/include/vivid/color.h @@ -3,7 +3,7 @@ #include "vivid/types.h" #include -namespace tq { +namespace vivid { class Color @@ -50,4 +50,4 @@ class Color Color lerp( const Color&, const Color&, const float ); -} // ::tq +} // ::vivid diff --git a/include/vivid/colormap.h b/include/vivid/colormap.h index 1753900..f0676bc 100644 --- a/include/vivid/colormap.h +++ b/include/vivid/colormap.h @@ -18,7 +18,7 @@ #include #include -namespace tq { +namespace vivid { class ColorMap @@ -66,4 +66,4 @@ class ColorMap }; -} // ::tq +} // ::vivid diff --git a/include/vivid/colortable.h b/include/vivid/colortable.h index c19d932..c99ee26 100644 --- a/include/vivid/colortable.h +++ b/include/vivid/colortable.h @@ -9,7 +9,7 @@ // [8] https://jonasjacek.github.io/colors/ -namespace tq { +namespace vivid { // 256 indexed ansi colors including names and various representations @@ -48,4 +48,4 @@ void printColorTable( ); -} // ::tq +} // ::vivid diff --git a/include/vivid/conversion.h b/include/vivid/conversion.h index ff7468e..e5df025 100644 --- a/include/vivid/conversion.h +++ b/include/vivid/conversion.h @@ -3,7 +3,7 @@ #include "vivid/types.h" #include -namespace tq { +namespace vivid { // xyz \in [ ( 0, 0, 0 ), ( 1, 1, 1 ) ] @@ -105,4 +105,4 @@ namespace name { } -} // ::tq +} // ::vivid diff --git a/include/vivid/encoding.h b/include/vivid/encoding.h index dfb12a1..d9d3464 100644 --- a/include/vivid/encoding.h +++ b/include/vivid/encoding.h @@ -5,7 +5,7 @@ #include -namespace tq::ansi +namespace vivid::ansi { inline std::string fg( const uint8_t index ) { return "\x1b[38;5;" + std::to_string( index ) + "m"; @@ -27,7 +27,7 @@ namespace tq::ansi } -namespace tq::html +namespace vivid::html { inline std::string fg( const std::string& hex ) { return ""; diff --git a/include/vivid/functions.h b/include/vivid/functions.h index f11957e..676b4e1 100644 --- a/include/vivid/functions.h +++ b/include/vivid/functions.h @@ -1,12 +1,11 @@ #pragma once #include "vivid/types.h" +#include "vivid/colormap.h" #include -class ColorMap; - -namespace tq::rgb +namespace vivid::rgb { col_t lerp( const col_t&, const col_t&, const float ); col_t lerpHsv( const col_t&, const col_t&, const float ); @@ -18,15 +17,15 @@ namespace tq::rgb col_t rainbow( const uint8_t k ); } -namespace tq::hsv { +namespace vivid::hsv { col_t lerp( const col_t&, const col_t&, const float ); } -namespace tq::hcl { +namespace vivid::hcl { col_t lerp( const col_t&, const col_t&, const float ); } -namespace tq::hsl +namespace vivid::hsl { col_t lerp( const col_t&, const col_t&, const float ); @@ -37,6 +36,6 @@ namespace tq::hsl ); } -namespace tq::ansi { +namespace vivid::ansi { std::string colorize( const std::string& text, const ColorMap& cmap ); } diff --git a/include/vivid/stream.h b/include/vivid/stream.h index 9de546a..7474b26 100644 --- a/include/vivid/stream.h +++ b/include/vivid/stream.h @@ -8,21 +8,21 @@ //////////////////////////////////////////////////////////////////////////////// -inline std::ostream& operator << ( std::ostream& out, const tq::col_t& col ) { +inline std::ostream& operator << ( std::ostream& out, const vivid::col_t& col ) { out << "col(" << std::setprecision( 3 ) << col.x << ", " << col.y << ", " << col.z << ")"; return out; } //////////////////////////////////////////////////////////////////////////////// -inline std::ostream& operator << ( std::ostream& out, const tq::col8_t& col ) { +inline std::ostream& operator << ( std::ostream& out, const vivid::col8_t& col ) { out << "rgb(" << int( col.x ) << ", " << int( col.y ) << ", " << int( col.z ) << ")"; return out; } //////////////////////////////////////////////////////////////////////////////// -inline std::ostream& operator << ( std::ostream& out, const tq::Color& col ) +inline std::ostream& operator << ( std::ostream& out, const vivid::Color& col ) { out << col.spaceInfo() << "("; out << std::setprecision( 3 ) << col.value().x << ", " << col.value().y << ", " << col.value().z; diff --git a/include/vivid/types.h b/include/vivid/types.h index c64640d..448def9 100644 --- a/include/vivid/types.h +++ b/include/vivid/types.h @@ -4,7 +4,7 @@ #include #include -namespace tq { +namespace vivid { using col_t = glm::vec<3, float>; @@ -31,4 +31,4 @@ inline bool fuzzyHueEqual( const col_t& c1, const col_t& c2 ) } -} // ::tq +} // ::vivid diff --git a/src/color.cpp b/src/color.cpp index 858b294..9ccd6a5 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -4,7 +4,7 @@ #include "vivid/functions.h" #include "vivid/stream.h" -namespace tq { +namespace vivid { //////////////////////////////////////////////////////////////////////////////// @@ -215,4 +215,4 @@ Color lerp( const Color& c1, const Color& c2, const float t ) } -} // ::tq +} // ::vivid diff --git a/src/colormap.cpp b/src/colormap.cpp index 708f8e1..de38e20 100644 --- a/src/colormap.cpp +++ b/src/colormap.cpp @@ -7,7 +7,7 @@ #include #include -namespace tq { +namespace vivid { //////////////////////////////////////////////////////////////////////////////// @@ -44,10 +44,10 @@ glm::vec3 ColorMap::at( const float t ) const switch ( interpolation ) { case InterpolationNearest: return stops_[ k ]; - case InterpolationLinear: return tq::rgb::lerp( stops_[ k ], stops_[ k + 1 ], u ); - case InterpolationHsv: return tq::rgb::lerpHsv( stops_[ k ], stops_[ k + 1 ], u ); - case InterpolationHsl: return tq::rgb::lerpHsl( stops_[ k ], stops_[ k + 1 ], u ); - case InterpolationHcl: return tq::rgb::lerpHcl( stops_[ k ], stops_[ k + 1 ], u ); + case InterpolationLinear: return vivid::rgb::lerp( stops_[ k ], stops_[ k + 1 ], u ); + case InterpolationHsv: return vivid::rgb::lerpHsv( stops_[ k ], stops_[ k + 1 ], u ); + case InterpolationHsl: return vivid::rgb::lerpHsl( stops_[ k ], stops_[ k + 1 ], u ); + case InterpolationHcl: return vivid::rgb::lerpHcl( stops_[ k ], stops_[ k + 1 ], u ); } return {}; @@ -105,4 +105,4 @@ std::vector ColorMap::loadFromFile( const std::string& filename ) } -} // ::tq +} // ::vivid diff --git a/src/colortable.cpp b/src/colortable.cpp index 7c716a3..4240ee1 100644 --- a/src/colortable.cpp +++ b/src/colortable.cpp @@ -11,7 +11,7 @@ #include // std::tolower -namespace tq { +namespace vivid { nlohmann::json ColorTable::table_ = {}; @@ -137,8 +137,8 @@ void printColorTable( const bool foreground, const bool background ) char idstr[ 4 ]; std::sprintf( idstr, "%03d", id ); - const std::string bgstr = tq::ansi::bg( id ) + " " + idstr + " " + tq::ansi::reset; - const std::string fgstr = tq::ansi::fg( id ) + " " + idstr + " " + tq::ansi::reset; + const std::string bgstr = vivid::ansi::bg( id ) + " " + idstr + " " + vivid::ansi::reset; + const std::string fgstr = vivid::ansi::fg( id ) + " " + idstr + " " + vivid::ansi::reset; if ( ! background ) { return fgstr; @@ -203,4 +203,4 @@ void printColorTable( const bool foreground, const bool background ) } -} // ::tq +} // ::vivid diff --git a/src/functions.cpp b/src/functions.cpp index 0284dae..d0f4fa4 100644 --- a/src/functions.cpp +++ b/src/functions.cpp @@ -12,7 +12,7 @@ #include #include -namespace tq::rgb { +namespace vivid::rgb { //////////////////////////////////////////////////////////////////////////////// @@ -29,7 +29,7 @@ col_t lerpHsv( { col_t hsv1 = hsv::fromRgb( rgb1 ); col_t hsv2 = hsv::fromRgb( rgb2 ); - return rgb::fromHsv( tq::hsv::lerp( hsv1, hsv2, t ) ); + return rgb::fromHsv( vivid::hsv::lerp( hsv1, hsv2, t ) ); } @@ -41,7 +41,7 @@ col_t lerpHsl( { col_t hsl1 = hsl::fromRgb( rgb1 ); col_t hsl2 = hsl::fromRgb( rgb2 ); - return rgb::fromHsl( tq::hsl::lerp( hsl1, hsl2, t ) ); + return rgb::fromHsl( vivid::hsl::lerp( hsl1, hsl2, t ) ); } @@ -53,7 +53,7 @@ col_t lerpHcl( { col_t lch1 = hcl::fromRgb( rgb1 ); col_t lch2 = hcl::fromRgb( rgb2 ); - return rgb::fromHcl( tq::hcl::lerp( lch1, lch2, t ) ); + return rgb::fromHcl( vivid::hcl::lerp( lch1, lch2, t ) ); } @@ -112,14 +112,14 @@ col_t saturate( const col_t& rgb ) //////////////////////////////////////////////////////////////////////////////// col_t clamp( const col_t& rgb ) { - return tq::rgb::fromIndex( tq::index::fromRgb( rgb ) ); + return vivid::rgb::fromIndex( vivid::index::fromRgb( rgb ) ); } -} // ::tq::rgb +} // ::vivid::rgb -namespace tq::hsl { +namespace vivid::hsl { //////////////////////////////////////////////////////////////////////////////// col_t rainbow( const uint8_t k, const float s, const float l ) { @@ -151,10 +151,10 @@ col_t lerp( return hsl; } -} // ::tq::hsl +} // ::vivid::hsl -namespace tq::hsv { +namespace vivid::hsv { //////////////////////////////////////////////////////////////////////////////// col_t lerp( @@ -179,10 +179,10 @@ col_t lerp( return hsv; } -} // ::tq::hsv +} // ::vivid::hsv -namespace tq::hcl { +namespace vivid::hcl { //////////////////////////////////////////////////////////////////////////////// col_t lerp( @@ -201,10 +201,10 @@ col_t lerp( return hcl1 + t * delta; } -} // ::tq::hcl +} // ::vivid::hcl -namespace tq::ansi { +namespace vivid::ansi { //////////////////////////////////////////////////////////////////////////////// std::string colorize( const std::string& text, const ColorMap& cmap ) @@ -218,12 +218,12 @@ std::string colorize( const std::string& text, const ColorMap& cmap ) for ( size_t i = 0; i < n; i++ ) { const float t = i / n; - const uint8_t id = tq::index::fromRgb( cmap.at( t ) ); - ss << tq::ansi::fg( id ) << text[ i ]; + const uint8_t id = vivid::index::fromRgb( cmap.at( t ) ); + ss << vivid::ansi::fg( id ) << text[ i ]; } - ss << tq::ansi::reset; + ss << vivid::ansi::reset; return ss.str(); } -} // ::tq::ansi +} // ::vivid::ansi diff --git a/src/hcl.cpp b/src/hcl.cpp index e8c1062..46d3567 100644 --- a/src/hcl.cpp +++ b/src/hcl.cpp @@ -1,7 +1,7 @@ #include "vivid/conversion.h" #include -namespace tq::hcl { +namespace vivid::hcl { //////////////////////////////////////////////////////////////////////////////// @@ -25,4 +25,4 @@ col_t fromRgb( const col_t& rgb ) { } -} // ::tq::cielch +} // ::vivid::cielch diff --git a/src/hex.cpp b/src/hex.cpp index d870329..94fa124 100644 --- a/src/hex.cpp +++ b/src/hex.cpp @@ -5,7 +5,7 @@ #include #include -namespace tq::hex { +namespace vivid::hex { ////////////////////////////////////////////////////////////////////////////////// @@ -37,4 +37,4 @@ std::string fromRgb32( const uint32_t rgb32 ) { } -} // ::tq::hex +} // ::vivid::hex diff --git a/src/hsl.cpp b/src/hsl.cpp index ca8348e..67bdb3a 100644 --- a/src/hsl.cpp +++ b/src/hsl.cpp @@ -6,7 +6,7 @@ #include #include -namespace tq::hsl { +namespace vivid::hsl { //////////////////////////////////////////////////////////////////////////////// @@ -54,4 +54,4 @@ col_t fromIndex( const uint8_t index ) { } -} // ::tq::hsl +} // ::vivid::hsl diff --git a/src/hsv.cpp b/src/hsv.cpp index 2887a14..da243c4 100644 --- a/src/hsv.cpp +++ b/src/hsv.cpp @@ -4,7 +4,7 @@ #include #include -namespace tq::hsv { +namespace vivid::hsv { //////////////////////////////////////////////////////////////////////////////// @@ -52,5 +52,5 @@ col_t fromHsl( const col_t& hsl ) { } -} // ::tq::hsv +} // ::vivid::hsv diff --git a/src/index.cpp b/src/index.cpp index 4871d19..739f523 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -2,7 +2,7 @@ #include "vivid/colortable.h" #include -namespace tq::index { +namespace vivid::index { ////////////////////////////////////////////////////////////////////////////////// @@ -54,4 +54,4 @@ uint8_t fromName( const std::string& name ) { } -} // ::tq::index +} // ::vivid::index diff --git a/src/lab.cpp b/src/lab.cpp index 3a7d0ad..95891cf 100644 --- a/src/lab.cpp +++ b/src/lab.cpp @@ -1,7 +1,7 @@ #include "vivid/conversion.h" #include -namespace tq::lab { +namespace vivid::lab { //////////////////////////////////////////////////////////////////////////////// @@ -42,4 +42,4 @@ col_t fromHcl( const col_t& hcl ) } -} // ::tq::cielab +} // ::vivid::cielab diff --git a/src/name.cpp b/src/name.cpp index 14b73ed..62c32b9 100644 --- a/src/name.cpp +++ b/src/name.cpp @@ -1,7 +1,7 @@ #include "vivid/conversion.h" #include "vivid/colortable.h" -namespace tq::name { +namespace vivid::name { //////////////////////////////////////////////////////////////////////////////// @@ -16,4 +16,4 @@ std::string fromIndex( const uint8_t index ) { } -} // ::tq::name +} // ::vivid::name diff --git a/src/rgb.cpp b/src/rgb.cpp index 591ac59..e7c931d 100644 --- a/src/rgb.cpp +++ b/src/rgb.cpp @@ -9,7 +9,7 @@ #include -namespace tq::rgb { +namespace vivid::rgb { //////////////////////////////////////////////////////////////////////////////// @@ -139,4 +139,4 @@ col_t fromName( const std::string& name ) { } -} // ::tq::rgb +} // ::vivid::rgb diff --git a/src/rgb32.cpp b/src/rgb32.cpp index 3380b2f..cecc46d 100644 --- a/src/rgb32.cpp +++ b/src/rgb32.cpp @@ -3,7 +3,7 @@ #include #include -namespace tq::rgb32 { +namespace vivid::rgb32 { //////////////////////////////////////////////////////////////////////////////// @@ -60,4 +60,4 @@ uint32_t fromHex( const std::string& hexStr ) } -} // ::tq::rgb32 +} // ::vivid::rgb32 diff --git a/src/rgb8.cpp b/src/rgb8.cpp index 39a53cb..aaec209 100644 --- a/src/rgb8.cpp +++ b/src/rgb8.cpp @@ -2,7 +2,7 @@ #include "vivid/colortable.h" #include -namespace tq::rgb8 { +namespace vivid::rgb8 { //////////////////////////////////////////////////////////////////////////////// @@ -40,4 +40,4 @@ col8_t fromName( const std::string& name ) { } -} // ::tq::rgb8 +} // ::vivid::rgb8 diff --git a/src/xyz.cpp b/src/xyz.cpp index de3a00f..d7d926c 100644 --- a/src/xyz.cpp +++ b/src/xyz.cpp @@ -1,7 +1,7 @@ #include "vivid/conversion.h" #include -namespace tq::xyz { +namespace vivid::xyz { //////////////////////////////////////////////////////////////////////////////// @@ -53,4 +53,4 @@ col_t fromRgb( const col_t& rgb ) } -} // ::tq::ciexyz +} // ::vivid::ciexyz diff --git a/tests/conversion.cpp b/tests/conversion.cpp index ecce89b..3ad1bd5 100644 --- a/tests/conversion.cpp +++ b/tests/conversion.cpp @@ -5,24 +5,22 @@ #include "utility.h" #include "catch.hpp" -using namespace tq; - -static const size_t fuzzIters = 10'000; - //////////////////////////////////////////////////////////////////////////////// TEST_CASE( "Direct Conversions", "[conversions]" ) { - ColorTable::initialize(); + using namespace vivid; + static const size_t fuzzIters = 10'000; + ColorTable::load( VIVID_ROOT_PATH "/res/colors.json" ); SECTION( "RGB8 -> RGB" ) { for ( size_t i = 0; i < fuzzIters; i++ ) { - const col8_t rgb8 = tq::rgb8::rand(); + const col8_t rgb8 = vivid::rgb8::rand(); const QColor qcol = { rgb8.x, rgb8.y, rgb8.z }; - const col_t rgb = tq::rgb::fromRgb8( rgb8 ); - const col_t qrgb = tq::rgb::fromQt( qcol ); + const col_t rgb = vivid::rgb::fromRgb8( rgb8 ); + const col_t qrgb = vivid::rgb::fromQt( qcol ); CAPTURE( rgb8, rgb, qrgb ); REQUIRE( fuzzyEqual( rgb, qrgb ) ); @@ -33,10 +31,10 @@ TEST_CASE( "Direct Conversions", "[conversions]" ) { for ( size_t i = 0; i < fuzzIters; i++ ) { - const col_t hsv = tq::rgb::rand(); + const col_t hsv = vivid::rgb::rand(); const QColor qhsv = QColor::fromHsvF( hsv.x, hsv.y, hsv.z ); - const col_t rgb = tq::rgb::fromHsv( hsv ); - const col_t qrgb = tq::rgb::fromQt( qhsv ); + const col_t rgb = vivid::rgb::fromHsv( hsv ); + const col_t qrgb = vivid::rgb::fromQt( qhsv ); CAPTURE( hsv, rgb, qrgb ); REQUIRE( fuzzyEqual( rgb, qrgb ) ); @@ -47,10 +45,10 @@ TEST_CASE( "Direct Conversions", "[conversions]" ) { for ( size_t i = 0; i < fuzzIters; i++ ) { - const col_t hsl = tq::rgb::rand(); + const col_t hsl = vivid::rgb::rand(); const QColor qhsl = QColor::fromHslF( hsl.x, hsl.y, hsl.z ); - const col_t rgb = tq::rgb::fromHsl( hsl ); - const col_t qrgb = tq::rgb::fromQt( qhsl ); + const col_t rgb = vivid::rgb::fromHsl( hsl ); + const col_t qrgb = vivid::rgb::fromQt( qhsl ); CAPTURE( hsl, rgb, qrgb ); REQUIRE( fuzzyEqual( rgb, qrgb ) ); @@ -61,9 +59,9 @@ TEST_CASE( "Direct Conversions", "[conversions]" ) { for ( size_t i = 0; i < fuzzIters; i++ ) { - const col_t col = tq::rgb::rand(); + const col_t col = vivid::rgb::rand(); const QColor qcol = QColor::fromRgbF( col.x, col.y, col.z ); - const col_t tar = tq::hsv::fromRgb( col ); + const col_t tar = vivid::hsv::fromRgb( col ); const col_t qtar = { qcol.hueF(), qcol.saturationF(), qcol.valueF() }; CAPTURE( col, tar, qtar ); @@ -75,9 +73,9 @@ TEST_CASE( "Direct Conversions", "[conversions]" ) { for ( size_t i = 0; i < fuzzIters; i++ ) { - const col_t col = tq::rgb::rand(); + const col_t col = vivid::rgb::rand(); const QColor qcol = QColor::fromRgbF( col.x, col.y, col.z ); - const col_t tar = tq::hsl::fromRgb( col ); + const col_t tar = vivid::hsl::fromRgb( col ); const col_t qtar = { qcol.hslHueF(), qcol.hslSaturationF(), qcol.lightnessF() }; CAPTURE( col, tar, qtar ); @@ -89,13 +87,13 @@ TEST_CASE( "Direct Conversions", "[conversions]" ) { for ( size_t i = 0; i < fuzzIters; i++ ) { - const col_t src = tq::rgb::rand(); - const auto rgb_1 = tq::rgb::fromHsl( src ); - const auto hsv_1 = tq::hsv::fromRgb( rgb_1 ); - const auto hsl_2 = tq::hsl::fromHsv( hsv_1 ); - const auto hsv_2 = tq::hsv::fromHsl( hsl_2 ); - const auto rgb_2 = tq::rgb::fromHsv( hsv_2 ); - const auto tar = tq::hsl::fromRgb( rgb_2 ); + const col_t src = vivid::rgb::rand(); + const auto rgb_1 = vivid::rgb::fromHsl( src ); + const auto hsv_1 = vivid::hsv::fromRgb( rgb_1 ); + const auto hsl_2 = vivid::hsl::fromHsv( hsv_1 ); + const auto hsv_2 = vivid::hsv::fromHsl( hsl_2 ); + const auto rgb_2 = vivid::rgb::fromHsv( hsv_2 ); + const auto tar = vivid::hsl::fromRgb( rgb_2 ); CAPTURE( src, tar ); REQUIRE( fuzzyHueEqual( src, tar ) ); @@ -106,7 +104,7 @@ TEST_CASE( "Direct Conversions", "[conversions]" ) { for ( size_t i = 0; i < fuzzIters; i++ ) { - const col_t src = tq::rgb::rand(); + const col_t src = vivid::rgb::rand(); const col_t xyz_1 = xyz::fromRgb( src ); const col_t lab_1 = lab::fromXyz( xyz_1 ); const col_t lch_1 = hcl::fromLab( lab_1 ); @@ -124,13 +122,13 @@ TEST_CASE( "Direct Conversions", "[conversions]" ) for ( size_t i = 0; i < fuzzIters; i++ ) { const uint8_t src = randi(); - const auto hex_1 = tq::hex::fromIndex( src ); - const auto rgb8_1 = tq::rgb8::fromHex( hex_1 ); - const auto rgb32_1 = tq::rgb32::fromRgb8( rgb8_1 ); - const auto rgb = tq::rgb::fromRgb32( rgb32_1 ); - const auto rgb32_2 = tq::rgb32::fromRgb( rgb ); - const auto rgb8_2 = tq::rgb8::fromRgb32( rgb32_2 ); - const auto hex_2 = tq::hex::fromRgb8( rgb8_2 ); + const auto hex_1 = vivid::hex::fromIndex( src ); + const auto rgb8_1 = vivid::rgb8::fromHex( hex_1 ); + const auto rgb32_1 = vivid::rgb32::fromRgb8( rgb8_1 ); + const auto rgb = vivid::rgb::fromRgb32( rgb32_1 ); + const auto rgb32_2 = vivid::rgb32::fromRgb( rgb ); + const auto rgb8_2 = vivid::rgb8::fromRgb32( rgb32_2 ); + const auto hex_2 = vivid::hex::fromRgb8( rgb8_2 ); // NOTE(tgurdan): hex values are not unique, so can't check indices CAPTURE( int( src ), hex_1, hex_2 ); diff --git a/tests/utility.h b/tests/utility.h index e1f31b9..072d6d7 100644 --- a/tests/utility.h +++ b/tests/utility.h @@ -25,21 +25,21 @@ inline int randi( const int from = 0, const int to = 255 ) }; -namespace tq::rgb { +namespace vivid::rgb { inline col_t rand() { return { randf(), randf(), randf() }; } } -namespace tq::rgb8 { +namespace vivid::rgb8 { inline col8_t rand() { return { randi(), randi(), randi() }; } } -namespace tq::rgb { +namespace vivid::rgb { inline col_t fromQt( const QColor& qcol ) { return { qcol.redF(), qcol.greenF(), qcol.blueF() }; }