libs/core/src/eu/core/color.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | namespace eu::core | ||
| 4 | { | ||
| 5 | |||
| 6 | |||
| 7 | /// A single color in a format to load directly into open gl texture(ABGR on little endian). | ||
| 8 | /// @see \ref color_from_rgba | ||
| 9 | enum class SingleColor : std::uint32_t {}; | ||
| 10 | |||
| 11 | /// Constructs a \ref SingleColor value from individual red, green, blue, and alpha components. | ||
| 12 | /// @param r The red component of the color (0x00 - 0xFF). | ||
| 13 | /// @param g The green component of the color (0x00 - 0xFF). | ||
| 14 | /// @param b The blue component of the color (0x00 - 0xFF). | ||
| 15 | /// @param a The alpha (opacity) component of the color (0x00 - 0xFF). | ||
| 16 | /// @return A \ref SingleColor value representing the color composed of the specified RGBA components. | ||
| 17 | 5 | constexpr SingleColor color_from_rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { | |
| 18 | 5 | return static_cast<SingleColor>((static_cast<uint32_t>(a) << 24) | | |
| 19 | 5 | (static_cast<uint32_t>(b) << 16) | | |
| 20 | 5 | (static_cast<uint32_t>(g) << 8) | | |
| 21 | 5 | (static_cast<uint32_t>(r))); | |
| 22 | } | ||
| 23 | |||
| 24 | |||
| 25 | } | ||
| 26 |