pub struct Rgb {
pub r: f32,
pub g: f32,
pub b: f32,
}Expand description
A linear-light RGB color with f32 components.
一个使用 f32 分量的线性光 RGB 颜色。
Components are conventionally in [0, 1] but are not clamped by default; lighting math may produce values outside the range, and conversion to ColorRgba8 clamps them.
分量通常位于 [0, 1] 内,但默认不会截断;光照运算可能产生超出该范围的值,转换为 ColorRgba8 时会进行截断。
Fields§
§r: f32Red component. 红色分量。
g: f32Green component. 绿色分量。
b: f32Blue component. 蓝色分量。
Implementations§
Source§impl Rgb
impl Rgb
Sourcepub const fn new(r: f32, g: f32, b: f32) -> Self
pub const fn new(r: f32, g: f32, b: f32) -> Self
Construct a color from three components. 用三个分量构造一个颜色。
Sourcepub fn to_rgba8(self) -> ColorRgba8
pub fn to_rgba8(self) -> ColorRgba8
Quantize to 8-bit RGBA, truncating toward zero. 量化到 8 位 RGBA,向零截断。
The as u8 cast saturates: values below 0 clamp to 0, values above 1 clamp to 255, and NaN clamps to 0.
as u8 转换是饱和的:小于 0 的值截断为 0,大于 1 的值截断为 255,NaN 截断为 0。
This matches the reference renderer’s (uint8_t)(color * 255.0f) behavior.
这与参考渲染器的 (uint8_t)(color * 255.0f) 行为一致。
Trait Implementations§
impl Copy for Rgb
impl StructuralPartialEq for Rgb
Auto Trait Implementations§
impl Freeze for Rgb
impl RefUnwindSafe for Rgb
impl Send for Rgb
impl Sync for Rgb
impl Unpin for Rgb
impl UnsafeUnpin for Rgb
impl UnwindSafe for Rgb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more