windows_composition/color.rs
1use super::*;
2
3/// A 32-bit sRGB color with premultiplied alpha semantics, matching the
4/// composition `Color` ABI (`Windows.UI.Color`).
5#[derive(Clone, Copy, Debug, PartialEq, Eq)]
6pub struct Color(pub(crate) bindings::Color);
7
8impl Color {
9 /// Creates an opaque color from red, green, and blue components.
10 pub const fn rgb(r: u8, g: u8, b: u8) -> Self {
11 Self(bindings::Color { a: 255, r, g, b })
12 }
13
14 /// Creates a color from red, green, blue, and alpha components.
15 pub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self {
16 Self(bindings::Color { a, r, g, b })
17 }
18}