ty_math/ty_rgba_color.rs
1/// An RGBA color generic over its component type `T`, each component in the
2/// range `[0, 1]`.
3///
4/// The component type defaults to `f32`, so `TyRgbaColor` is the `f32` color;
5/// see `TyRgbaColorF32` and `TyRgbaColorF64` for the common instantiations.
6#[derive(Clone, Copy, Debug, Default, PartialEq)]
7pub struct TyRgbaColor<T = f32> {
8 /// The red component, in the range `[0, 1]`.
9 pub r: T,
10
11 /// The green component, in the range `[0, 1]`.
12 pub g: T,
13
14 /// The blue component, in the range `[0, 1]`.
15 pub b: T,
16
17 /// The alpha component, in the range `[0, 1]`.
18 pub a: T,
19}
20
21impl<T> TyRgbaColor<T> {
22 /// Creates a new color from `r`, `g`, `b`, and `a` components.
23 pub fn new(r: T, g: T, b: T, a: T) -> Self {
24 Self { r, g, b, a }
25 }
26}