|
aest 0.1.0
Collection of C++ utility libraries
|
Mixin adding channel-wise arithmetic operators to a color type. More...
Private Member Functions | |
| constexpr Derived & | self () noexcept |
| Access this object as the derived color type. | |
Arithmetic operators | |
| constexpr Derived | operator+ (const Derived &lhs, const Derived &rhs) noexcept |
| Adds two colors together, channel by channel. | |
| constexpr Derived | operator- (const Derived &lhs, const Derived &rhs) noexcept |
| Subtracts a color from another, channel by channel. | |
| constexpr Derived | operator* (const Derived &lhs, const Derived &rhs) noexcept |
| Multiplies two colors, channel by channel. | |
| constexpr Derived & | operator+= (const Derived &other) noexcept |
| Adds another color to this color in place. | |
| constexpr Derived & | operator-= (const Derived &other) noexcept |
| Subtracts another color from this color in place. | |
| constexpr Derived & | operator*= (const Derived &other) noexcept |
| Multiplies this color by another color in place. | |
Scalar operators | |
| constexpr Derived | operator* (const Derived &color, const float scalar) noexcept |
| Scales the color channels of a color, keeping its alpha. | |
| constexpr Derived | operator* (const float scalar, const Derived &color) noexcept |
| Scales the color channels of a color, keeping its alpha. | |
| constexpr Derived | operator/ (const Derived &color, const float scalar) noexcept |
| Divides the color channels of a color, keeping its alpha. | |
| constexpr Derived & | operator*= (const float scalar) noexcept |
| Scales the color channels of this color in place, keeping its alpha. | |
| constexpr Derived & | operator/= (const float scalar) noexcept |
| Divides the color channels of this color in place, keeping its alpha. | |
Mixin adding channel-wise arithmetic operators to a color type.
Inherit it only in color spaces where adding and multiplying channel values is meaningful, such as LinSRGB. Every operator combines both operands on all four channels, alpha included: two half-transparent colors add up to an opaque one, and a - a is fully transparent. The results are built through the derived type's (ch1, ch2, ch3, alpha) constructor, so they are clamped like any other value of that type: LinSRGB channels stop at 0 but not at 1, and alpha stays in the 0-1 range.
The scalar operators are the exception: color * s and color / s scale the light, the three color channels, and keep alpha, as exposure or a light's intensity would.
| Derived | The derived color class |
Definition at line 250 of file Color.cppm.
|
inlineconstexprnoexcept |
Multiplies this color by another color in place.
| [in] | other | The color to multiply by. |
Definition at line 309 of file Color.cppm.
|
inlineconstexprnoexcept |
Scales the color channels of this color in place, keeping its alpha.
| [in] | scalar | The factor applied to each color channel. |
scalar is finite. Definition at line 358 of file Color.cppm.
|
inlineconstexprnoexcept |
Adds another color to this color in place.
| [in] | other | The color to add. |
Definition at line 295 of file Color.cppm.
|
inlineconstexprnoexcept |
Subtracts another color from this color in place.
| [in] | other | The color to subtract. |
Definition at line 302 of file Color.cppm.
|
inlineconstexprnoexcept |
Divides the color channels of this color in place, keeping its alpha.
| [in] | scalar | The divisor of each color channel. |
scalar is finite and not 0. Definition at line 366 of file Color.cppm.
|
inlineconstexprprivatenoexcept |
Access this object as the derived color type.
Definition at line 374 of file Color.cppm.
|
friend |
Scales the color channels of a color, keeping its alpha.
| [in] | color | The color to scale. |
| [in] | scalar | The factor applied to each color channel. |
color. scalar is finite. Definition at line 321 of file Color.cppm.
|
friend |
Multiplies two colors, channel by channel.
| [in] | lhs | The left-hand color. |
| [in] | rhs | The right-hand color. |
Definition at line 284 of file Color.cppm.
|
friend |
Scales the color channels of a color, keeping its alpha.
| [in] | scalar | The factor applied to each color channel. |
| [in] | color | The color to scale. |
color. scalar is finite. Definition at line 334 of file Color.cppm.
|
friend |
Adds two colors together, channel by channel.
| [in] | lhs | The left-hand color. |
| [in] | rhs | The right-hand color. |
Definition at line 260 of file Color.cppm.
|
friend |
Subtracts a color from another, channel by channel.
| [in] | lhs | The color to subtract from. |
| [in] | rhs | The color to subtract. |
Definition at line 272 of file Color.cppm.
|
friend |
Divides the color channels of a color, keeping its alpha.
| [in] | color | The color to divide. |
| [in] | scalar | The divisor of each color channel. |
color. scalar is finite and not 0. Definition at line 346 of file Color.cppm.