ui::Color¶
Header: winui/core/Color.hpp.
An RGBA color with float channels in 0..1 and straight (non-premultiplied) alpha.
The value type every brush, theme palette entry and render command uses. Channels hold the sRGB-encoded values as authored (not linearized); a defaults to opaque. Build one from 8-bit channels with from_rgba(), from_rgb() or from_argb(), or use a named constant from colors.
Example:
const ui::Color accent = ui::Color::from_argb(0xFF0078D4);
const ui::Color hover = ui::lerp(accent, ui::colors::White, 0.2f);
window.set_content(ui::Button{
.text = "Save",
.background = hover.with_alpha(0.9f),
.foreground = ui::colors::White,
});
r¶
Red, 0..1.
g¶
Green, 0..1.
b¶
Blue, 0..1.
a¶
Straight alpha, 0 (transparent) .. 1 (opaque).
Color¶
Opaque black.
Color¶
constexpr Color(std::floating_point auto red, std::floating_point auto green, std::floating_point auto blue)
From float channels in 0..1, opaque: ui::Color{1.0f, 0.5f, 0.0f}.
Color¶
constexpr Color(std::floating_point auto red, std::floating_point auto green, std::floating_point auto blue, std::floating_point auto alpha)
From float channels and alpha in 0..1: ui::Color{1.0f, 0.5f, 0.0f, 0.5f}.
Color¶
template <std::integral R, std::integral G, std::integral B, std::integral... A>
constexpr Color(R, G, B, A...)
requires (sizeof...(A) <= 1)
Integer channels do not compile: Color{255, 128, 0} would be white, since a channel is 0..1. 8-bit channels go through from_rgb() or from_rgba().
with_alpha¶
A copy with a replaced by alpha (0..1, not clamped); r/g/b are untouched.
from_rgba¶
Construct from 8-bit sRGB channels (0..255); alpha defaults to opaque.
from_argb¶
Construct from a packed 0xAARRGGBB value (#AARRGGBB order), so 0xFF0078D4 is an opaque blue. A value written as 0xRRGGBB has alpha 0 and is fully transparent. Use from_rgb() for that.
from_rgb¶
Construct an opaque color from a packed 0xRRGGBB value (#RRGGBB), so 0x0078D4 is the same blue. Bits above the low 24 are ignored.
from_rgb¶
Construct an opaque color from 8-bit sRGB channels (0..255): from_rgb(0, 120, 212).