Browse Source

Math: default-constructed Color4 should have zero alpha.

Makes more sense than fully opaque black. On the other hand, creating
Color4 from Color3 or separate RGB components still sets alpha to one,
because that's the intuitive behavior.
pull/183/head^2
Vladimír Vondruš 10 years ago
parent
commit
dce3880d13
  1. 5
      src/Magnum/Math/Color.h
  2. 2
      src/Magnum/Math/Test/ColorTest.cpp

5
src/Magnum/Math/Color.h

@ -445,10 +445,9 @@ class Color4: public Vector4<T> {
/**
* @brief Default constructor
*
* RGB components are set to zero, A component is set to `1.0` for
* floating-point types and maximum positive value for integral types.
* All components are set to zero.
*/
constexpr /*implicit*/ Color4(): Vector4<T>(T(0), T(0), T(0), Implementation::fullChannel<T>()) {}
constexpr /*implicit*/ Color4(): Vector4<T>(T(0), T(0), T(0), T(0)) {}
/** @copydoc Vector::Vector(ZeroInitT) */
constexpr explicit Color4(ZeroInitT)

2
src/Magnum/Math/Test/ColorTest.cpp

@ -125,7 +125,7 @@ void ColorTest::constructDefault() {
constexpr Color4 b;
constexpr Color4ub c;
CORRADE_COMPARE(b, Color4(0.0f, 0.0f, 0.0f, 1.0f));
CORRADE_COMPARE(b, Color4(0.0f, 0.0f, 0.0f, 0.0f));
CORRADE_COMPARE(c, Color4ub(0, 0, 0, 255));
}

Loading…
Cancel
Save