diff --git a/src/Magnum/Math/Color.h b/src/Magnum/Math/Color.h index ef84cde98..d4963a773 100644 --- a/src/Magnum/Math/Color.h +++ b/src/Magnum/Math/Color.h @@ -568,6 +568,14 @@ template class Color3: public Vector3 { */ constexpr /*implicit*/ Color3(T r, T g, T b) noexcept: Vector3(r, g, b) {} + /** + * @brief Constructor + * @param rg RG value + * @param b B value + * @m_since_latest + */ + constexpr /*implicit*/ Color3(const Vector<2, T>& rg, T b) noexcept: Vector3{rg, b} {} + /** * @copydoc Vector::Vector(const Vector&) * diff --git a/src/Magnum/Math/Test/ColorTest.cpp b/src/Magnum/Math/Test/ColorTest.cpp index 6890a0238..bcd112497 100644 --- a/src/Magnum/Math/Test/ColorTest.cpp +++ b/src/Magnum/Math/Test/ColorTest.cpp @@ -156,6 +156,7 @@ struct ColorTest: Corrade::TestSuite::Tester { #endif }; +typedef Math::Vector2 Vector2; typedef Math::Vector3 Vector3; typedef Math::Vector3 Vector3ub; typedef Math::Vector3 Vector3us; @@ -387,18 +388,21 @@ void ColorTest::constructOneValue() { } void ColorTest::constructParts() { - constexpr Color3 a(1.0f, 0.5f, 0.75f); + constexpr Vector2 a{1.0f, 0.5f}; + constexpr Color3 b = {a, 0.75f}; + CORRADE_COMPARE(b, (Color3{1.0f, 0.5f, 0.75f})); - constexpr Color4 b = {a, 0.25f}; - CORRADE_COMPARE(b, Color4(1.0f, 0.5f, 0.75f, 0.25f)); + constexpr Color4 c = {b, 0.25f}; + CORRADE_COMPARE(c, (Color4{1.0f, 0.5f, 0.75f, 0.25f})); /* Default alpha */ - constexpr Color3ub c(10, 25, 176); - constexpr Color4 d = a; - constexpr Color4ub e = c; - CORRADE_COMPARE(d, Color4(1.0f, 0.5f, 0.75f, 1.0f)); - CORRADE_COMPARE(e, Color4ub(10, 25, 176, 255)); + constexpr Color3ub d(10, 25, 176); + constexpr Color4 e = b; + constexpr Color4ub f = d; + CORRADE_COMPARE(e, (Color4{1.0f, 0.5f, 0.75f, 1.0f})); + CORRADE_COMPARE(f, (Color4ub{10, 25, 176, 255})); + CORRADE_VERIFY(std::is_nothrow_constructible::value); CORRADE_VERIFY(std::is_nothrow_constructible::value); }