Struct colorsys::RgbRatio [−][src]
Rgb representation as ratio (from 0.0
to 1.0
).
Cannot be modified, added, subtracted, etc. Can be converted to Rgb
and vice versa.
Used for compatibility in various libraries.
Example
use colorsys::{ApproxEq, Rgb, RgbRatio}; let origin = Rgb::from([134.9, 11.1, 250.55, 1.0]); let ratio_f32: [f32; 4] = origin.as_ratio().into(); let ratio_f64: [f64; 3] = origin.as_ratio().into(); // ~[0.5290196, 0.04352941, 0.982549] let converted_f32: Rgb = RgbRatio::from(&ratio_f32).into(); let converted_f64: Rgb = RgbRatio::from(&ratio_f64).into(); assert!(origin.approx_eq_clarify(&converted_f32, 0.0001)); assert!(origin.approx_eq(&converted_f64));
Implementations
impl RgbRatio
[src]
pub fn new(r: f64, g: f64, b: f64, a: f64) -> Self
[src]
pub fn r(&self) -> f64
[src]
pub fn g(&self) -> f64
[src]
pub fn b(&self) -> f64
[src]
pub fn a(&self) -> f64
[src]
Trait Implementations
impl AsRef<RgbRatio> for RgbRatio
[src]
impl Clone for RgbRatio
[src]
impl Debug for RgbRatio
[src]
impl From<&'_ [f32; 3]> for RgbRatio
[src]
impl From<&'_ [f32; 4]> for RgbRatio
[src]
impl From<&'_ [f64; 3]> for RgbRatio
[src]
impl From<&'_ [f64; 4]> for RgbRatio
[src]
impl From<&'_ (f32, f32, f32, f32)> for RgbRatio
[src]
impl From<&'_ (f32, f32, f32)> for RgbRatio
[src]
impl From<&'_ (f64, f64, f64, f64)> for RgbRatio
[src]
impl From<&'_ (f64, f64, f64)> for RgbRatio
[src]
impl From<&'_ RgbRatio> for Rgb
[src]
impl From<&'_ mut RgbRatio> for Rgb
[src]
impl From<[f32; 3]> for RgbRatio
[src]
impl From<[f32; 4]> for RgbRatio
[src]
impl From<[f64; 3]> for RgbRatio
[src]
impl From<[f64; 4]> for RgbRatio
[src]
impl From<(f32, f32, f32, f32)> for RgbRatio
[src]
impl From<(f32, f32, f32)> for RgbRatio
[src]
impl From<(f64, f64, f64, f64)> for RgbRatio
[src]
impl From<(f64, f64, f64)> for RgbRatio
[src]
impl From<RgbRatio> for Rgb
[src]
impl<'a> Into<[f32; 3]> for &'a RgbRatio
[src]
impl<'a> Into<[f32; 3]> for &'a mut RgbRatio
[src]
impl Into<[f32; 3]> for RgbRatio
[src]
impl<'a> Into<[f32; 4]> for &'a RgbRatio
[src]
impl<'a> Into<[f32; 4]> for &'a mut RgbRatio
[src]
impl Into<[f32; 4]> for RgbRatio
[src]
impl<'a> Into<[f64; 3]> for &'a RgbRatio
[src]
impl<'a> Into<[f64; 3]> for &'a mut RgbRatio
[src]
impl Into<[f64; 3]> for RgbRatio
[src]
impl<'a> Into<[f64; 4]> for &'a RgbRatio
[src]
impl<'a> Into<[f64; 4]> for &'a mut RgbRatio
[src]
impl Into<[f64; 4]> for RgbRatio
[src]
impl<'a> Into<(f32, f32, f32, f32)> for &'a RgbRatio
[src]
impl<'a> Into<(f32, f32, f32, f32)> for &'a mut RgbRatio
[src]
impl Into<(f32, f32, f32, f32)> for RgbRatio
[src]
impl<'a> Into<(f32, f32, f32)> for &'a RgbRatio
[src]
impl<'a> Into<(f32, f32, f32)> for &'a mut RgbRatio
[src]
impl Into<(f32, f32, f32)> for RgbRatio
[src]
impl<'a> Into<(f64, f64, f64, f64)> for &'a RgbRatio
[src]
impl<'a> Into<(f64, f64, f64, f64)> for &'a mut RgbRatio
[src]
impl Into<(f64, f64, f64, f64)> for RgbRatio
[src]
impl<'a> Into<(f64, f64, f64)> for &'a RgbRatio
[src]
impl<'a> Into<(f64, f64, f64)> for &'a mut RgbRatio
[src]
impl Into<(f64, f64, f64)> for RgbRatio
[src]
impl<'a> Into<RgbRatio> for &'a Rgb
[src]
impl<'a> Into<RgbRatio> for &'a mut Rgb
[src]
impl Into<RgbRatio> for Rgb
[src]
impl PartialEq<RgbRatio> for RgbRatio
[src]
impl StructuralPartialEq for RgbRatio
[src]
Auto Trait Implementations
impl RefUnwindSafe for RgbRatio
[src]
impl Send for RgbRatio
[src]
impl Sync for RgbRatio
[src]
impl Unpin for RgbRatio
[src]
impl UnwindSafe for RgbRatio
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,