|
aest 0.1.0
Collection of C++ utility libraries
|
A color of a linear space with premultiplied alpha: each color channel is already multiplied by alpha. More...
Public Member Functions | |
| constexpr | Premultiplied () |
| Default constructor initializes the color to opaque black (0, 0, 0, 1). | |
| constexpr | Premultiplied (const float ch1, const float ch2, const float ch3, const float a=1.0f) |
| Construct a color from premultiplied channel values. | |
| Public Member Functions inherited from aest::colors::ColorBase< Premultiplied< Space > > | |
| constexpr float | alpha () const noexcept |
| Get the alpha channel value in the 0-1 range. | |
| constexpr float | ch1 () const noexcept |
| Get the first channel value. | |
| constexpr float | ch2 () const noexcept |
| Get the second channel value. | |
| constexpr float | ch3 () const noexcept |
| Get the third channel value. | |
| constexpr Premultiplied< Space > | opacity (const float alpha) const |
| Returns a new color with the same channels and the specified alpha value. | |
Static Public Attributes | |
| static constexpr std::string_view | TYPE {TYPE_CHARS.data(), TYPE_CHARS.size()} |
| Color space name, used by the std::formatter specialization. | |
Private Member Functions | |
| constexpr | Premultiplied (const Space &clamped) |
Construct a color from channels already clamped by Space. | |
Static Private Attributes | |
| static constexpr std::string_view | TYPE_PREFIX = "Premultiplied<" |
Beginning of the space name, before the name of Space. | |
| static constexpr auto | TYPE_CHARS |
| The space name, Premultiplied< + Space::TYPE + >. | |
Arithmetic operators | |
| constexpr Premultiplied & | operator+= (const Premultiplied &other) noexcept |
| Adds another color to this color in place. | |
| constexpr Premultiplied & | operator*= (const float scalar) noexcept |
| Scales every channel of this color in place, alpha included. | |
| constexpr Premultiplied | operator+ (const Premultiplied &lhs, const Premultiplied &rhs) noexcept |
| Adds two colors, alpha included, as when one adds its light and coverage on top of the other. | |
| constexpr Premultiplied | operator* (const Premultiplied &color, const float scalar) noexcept |
| Scales every channel of a color, alpha included, as when fading it. | |
| constexpr Premultiplied | operator* (const float scalar, const Premultiplied &color) noexcept |
| Scales every channel of a color, alpha included, as when fading it. | |
Additional Inherited Members | |
| Public Attributes inherited from aest::colors::ColorBase< Premultiplied< Space > > | |
| friend | Derived |
| Lets the derived color reach the private constructor and channels. | |
A color of a linear space with premultiplied alpha: each color channel is already multiplied by alpha.
This is the form compositing works in: a premultiplied color is the light it adds plus the fraction of the background it covers, so blending is a sum. Its channels are clamped like those of Space; alpha is clamped to the 0-1 range. Convert from and to Space with convert(): converting a color whose alpha is 0 back to Space gives transparent black.
| Space | The linear color space of the channels, such as LinSRGB |
Definition at line 46 of file Compositing.cppm.
|
inlineconstexpr |
Default constructor initializes the color to opaque black (0, 0, 0, 1).
Definition at line 60 of file Compositing.cppm.
|
inlineconstexpr |
Construct a color from premultiplied channel values.
| [in] | ch1 | First channel, already multiplied by a |
| [in] | ch2 | Second channel, already multiplied by a |
| [in] | ch3 | Third channel, already multiplied by a |
| [in] | a | Alpha channel value (default 1.0) |
Definition at line 72 of file Compositing.cppm.
|
inlineexplicitconstexprprivate |
Construct a color from channels already clamped by Space.
| [in] | clamped | The premultiplied channels, held in a Space value |
Definition at line 146 of file Compositing.cppm.
|
inlineconstexprnoexcept |
Scales every channel of this color in place, alpha included.
| [in] | scalar | The factor applied to each channel. |
scalar is finite. Definition at line 135 of file Compositing.cppm.
|
inlineconstexprnoexcept |
Adds another color to this color in place.
| [in] | other | The color to add. |
Definition at line 124 of file Compositing.cppm.
|
friend |
Scales every channel of a color, alpha included, as when fading it.
| [in] | scalar | The factor applied to each channel. |
| [in] | color | The color to scale. |
scalar is finite. Definition at line 113 of file Compositing.cppm.
|
friend |
Scales every channel of a color, alpha included, as when fading it.
| [in] | color | The color to scale. |
| [in] | scalar | The factor applied to each channel. |
scalar is finite. Definition at line 99 of file Compositing.cppm.
|
friend |
Adds two colors, alpha included, as when one adds its light and coverage on top of the other.
| [in] | lhs | The left-hand color. |
| [in] | rhs | The right-hand color. |
Definition at line 85 of file Compositing.cppm.
|
staticconstexpr |
Color space name, used by the std::formatter specialization.
Definition at line 57 of file Compositing.cppm.
|
staticconstexprprivate |
The space name, Premultiplied< + Space::TYPE + >.
Definition at line 52 of file Compositing.cppm.
|
staticconstexprprivate |
Beginning of the space name, before the name of Space.
Definition at line 49 of file Compositing.cppm.