pub struct Color {
pub r: f64,
pub g: f64,
pub b: f64,
}Expand description
Port of three.js/src/math/Color.js’s Color class: an RGB color, stored
in the working color space (linear-sRGB).
Fields§
§r: f64The red channel.
g: f64The green channel.
b: f64The blue channel.
Implementations§
Source§impl Color
impl Color
Sourcepub const fn new(r: f64, g: f64, b: f64) -> Self
pub const fn new(r: f64, g: f64, b: f64) -> Self
new Color( r, g, b ) / setRGB( r, g, b ) with the working colour
space, i.e. the components are stored as given.
Sourcepub fn set_scalar(&mut self, scalar: f64) -> &mut Self
pub fn set_scalar(&mut self, scalar: f64) -> &mut Self
Color.setScalar().
Sourcepub fn set_hex(&mut self, hex: u32, color_space: ColorSpace) -> &mut Self
pub fn set_hex(&mut self, hex: u32, color_space: ColorSpace) -> &mut Self
Color.setHex().
Sourcepub fn set_rgb(
&mut self,
r: f64,
g: f64,
b: f64,
color_space: ColorSpace,
) -> &mut Self
pub fn set_rgb( &mut self, r: f64, g: f64, b: f64, color_space: ColorSpace, ) -> &mut Self
Color.setRGB().
Sourcepub fn set_hsl(
&mut self,
h: f64,
s: f64,
l: f64,
color_space: ColorSpace,
) -> &mut Self
pub fn set_hsl( &mut self, h: f64, s: f64, l: f64, color_space: ColorSpace, ) -> &mut Self
Color.setHSL(). h, s and l are in 0..1.
Sourcepub fn copy_srgb_to_linear(&mut self, color: &Self) -> &mut Self
pub fn copy_srgb_to_linear(&mut self, color: &Self) -> &mut Self
Color.copySRGBToLinear().
Sourcepub fn copy_linear_to_srgb(&mut self, color: &Self) -> &mut Self
pub fn copy_linear_to_srgb(&mut self, color: &Self) -> &mut Self
Color.copyLinearToSRGB().
Sourcepub fn convert_srgb_to_linear(&mut self) -> &mut Self
pub fn convert_srgb_to_linear(&mut self) -> &mut Self
Color.convertSRGBToLinear().
Sourcepub fn convert_linear_to_srgb(&mut self) -> &mut Self
pub fn convert_linear_to_srgb(&mut self) -> &mut Self
Color.convertLinearToSRGB().
Sourcepub fn get_hex(&self, color_space: ColorSpace) -> u32
pub fn get_hex(&self, color_space: ColorSpace) -> u32
Color.getHex().
Sourcepub fn get_hex_string(&self, color_space: ColorSpace) -> String
pub fn get_hex_string(&self, color_space: ColorSpace) -> String
Color.getHexString().
Sourcepub fn get_hsl(&self, color_space: ColorSpace) -> Hsl
pub fn get_hsl(&self, color_space: ColorSpace) -> Hsl
Color.getHSL().
Sourcepub fn get_rgb(&self, color_space: ColorSpace) -> Self
pub fn get_rgb(&self, color_space: ColorSpace) -> Self
Color.getRGB().
Sourcepub fn offset_hsl(&mut self, h: f64, s: f64, l: f64) -> &mut Self
pub fn offset_hsl(&mut self, h: f64, s: f64, l: f64) -> &mut Self
Color.offsetHSL().
Sourcepub fn add_colors(&mut self, color1: &Self, color2: &Self) -> &mut Self
pub fn add_colors(&mut self, color1: &Self, color2: &Self) -> &mut Self
Color.addColors().
Sourcepub fn add_scalar(&mut self, s: f64) -> &mut Self
pub fn add_scalar(&mut self, s: f64) -> &mut Self
Color.addScalar().
Sourcepub fn multiply_scalar(&mut self, s: f64) -> &mut Self
pub fn multiply_scalar(&mut self, s: f64) -> &mut Self
Color.multiplyScalar().
Sourcepub fn lerp_colors(
&mut self,
color1: &Self,
color2: &Self,
alpha: f64,
) -> &mut Self
pub fn lerp_colors( &mut self, color1: &Self, color2: &Self, alpha: f64, ) -> &mut Self
Color.lerpColors().
Sourcepub fn set_from_vector3(&mut self, v: &Vector3) -> &mut Self
pub fn set_from_vector3(&mut self, v: &Vector3) -> &mut Self
Color.setFromVector3().
Sourcepub fn apply_matrix3(&mut self, m: &Matrix3) -> &mut Self
pub fn apply_matrix3(&mut self, m: &Matrix3) -> &mut Self
Color.applyMatrix3().
Sourcepub fn from_array(&mut self, array: &[f64], offset: usize) -> &mut Self
pub fn from_array(&mut self, array: &[f64], offset: usize) -> &mut Self
Color.fromArray().
Trait Implementations§
impl Copy for Color
Source§impl From<Color> for RangeValue
impl From<Color> for RangeValue
Source§impl From<Color> for Background
impl From<Color> for Background
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnsafeUnpin for Color
impl UnwindSafe for Color
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