Partition aest.colors:color: color types, their shared base and the ColorType concept.
More...
#include <algorithm>
#include <array>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <initializer_list>
#include <numbers>
#include <string_view>
Go to the source code of this file.
|
| constexpr float | aest::colors::clamp (const float value) |
| | Clamp a floating-point value to the 0-1 range.
|
| constexpr float | aest::colors::non_negative (const float value) |
| | Clamp a floating-point value to be non-negative, leaving it unbounded above.
|
| constexpr float | aest::colors::to_float (const std::uint8_t value) |
| | Convert an 8-bit color channel value to a float in the 0-1 range.
|
| constexpr std::uint8_t | aest::colors::to_byte (const float value) |
| | Convert a float in the 0-1 range to a 8-bit color channel value.
|
| constexpr std::uint8_t | aest::colors::byte_at (const std::uint32_t word, const std::uint32_t index) |
| | Extract one byte of a 32-bit word.
|
| constexpr std::uint32_t | aest::colors::pack (const std::uint8_t byte3, const std::uint8_t byte2, const std::uint8_t byte1, const std::uint8_t byte0) |
| | Pack four bytes into a 32-bit word, most significant first.
|
| template<std::size_t Size> |
| constexpr std::array< char, Size > | aest::colors::join_names (const std::initializer_list< std::string_view > parts) |
| | Concatenate names into a character array, for a color space name built at compile time.
|
| constexpr float | aest::colors::wrap_hue (const float hue) |
| | Wrap a hue angle to the [0, 360) range.
|
Partition aest.colors:color: color types, their shared base and the ColorType concept.
- Copyright
- Copyright (c) 2026 Davide Pierotti, MIT License (see LICENSE.md)
- Author
- Davide Pierotti
Definition in file Color.cppm.
◆ byte_at()
| std::uint8_t aest::colors::byte_at |
( |
const std::uint32_t | word, |
|
|
const std::uint32_t | index ) |
|
constexpr |
Extract one byte of a 32-bit word.
- Parameters
-
| [in] | word | The word to read |
| [in] | index | Position of the byte, 0 being the least significant |
- Returns
- The byte at
index.
Definition at line 70 of file Color.cppm.
◆ clamp()
| float aest::colors::clamp |
( |
const float | value | ) |
|
|
constexpr |
Clamp a floating-point value to the 0-1 range.
- Parameters
-
| [in] | value | The value to clamp |
- Returns
- The clamped value
Definition at line 29 of file Color.cppm.
◆ join_names()
template<std::size_t Size>
| std::array< char, Size > aest::colors::join_names |
( |
const std::initializer_list< std::string_view > | parts | ) |
|
|
constexpr |
Concatenate names into a character array, for a color space name built at compile time.
- Template Parameters
-
| Size | The total length of parts |
- Parameters
-
| [in] | parts | The names to join, in order |
- Returns
- The characters of
parts, without a terminator.
Definition at line 100 of file Color.cppm.
◆ non_negative()
| float aest::colors::non_negative |
( |
const float | value | ) |
|
|
constexpr |
Clamp a floating-point value to be non-negative, leaving it unbounded above.
- Parameters
-
| [in] | value | The value to clamp |
- Returns
- The value, or 0 when it is negative
Definition at line 39 of file Color.cppm.
◆ pack()
| std::uint32_t aest::colors::pack |
( |
const std::uint8_t | byte3, |
|
|
const std::uint8_t | byte2, |
|
|
const std::uint8_t | byte1, |
|
|
const std::uint8_t | byte0 ) |
|
constexpr |
Pack four bytes into a 32-bit word, most significant first.
- Parameters
-
| [in] | byte3 | The most significant byte |
| [in] | byte2 | The second byte |
| [in] | byte1 | The third byte |
| [in] | byte0 | The least significant byte |
- Returns
- The word with
byte3 in the top byte and byte0 in the bottom one.
Definition at line 83 of file Color.cppm.
◆ to_byte()
| std::uint8_t aest::colors::to_byte |
( |
const float | value | ) |
|
|
constexpr |
Convert a float in the 0-1 range to a 8-bit color channel value.
- Parameters
-
| [in] | value | The color value in the 0-1 range. |
- Returns
- The nearest 8-bit representation.
Definition at line 59 of file Color.cppm.
◆ to_float()
| float aest::colors::to_float |
( |
const std::uint8_t | value | ) |
|
|
constexpr |
Convert an 8-bit color channel value to a float in the 0-1 range.
- Parameters
-
| [in] | value | The 8-bit color channel value |
- Returns
- The corresponding float value in the 0-1 range
Definition at line 49 of file Color.cppm.
◆ wrap_hue()
| float aest::colors::wrap_hue |
( |
const float | hue | ) |
|
|
constexpr |
Wrap a hue angle to the [0, 360) range.
- Parameters
-
| [in] | hue | The hue in degrees, any finite value whose whole turns fit a std::int64_t. |
- Returns
- The equivalent hue in the [0, 360) range.
Definition at line 118 of file Color.cppm.
◆ BYTE_MAX
| std::uint8_t aest::colors::BYTE_MAX = 255 |
|
inlineconstexpr |
Maximum value for an 8-bit color channel.
Definition at line 22 of file Color.cppm.
◆ DEGREES_PER_RADIAN
| double aest::colors::DEGREES_PER_RADIAN = 180.0 / std::numbers::pi |
|
constexpr |