[−][src]Struct cube_helix::CubeHelix
Examples
Using default values:
use cube_helix::CubeHelix; // Get default values let ch: CubeHelix = Default::default(); // Returns color white: (255,255,255) let color = ch.get_color(1.0); assert_eq!(color.0, 255); assert_eq!(color.1, 255); assert_eq!(color.2, 255);
Using defaults partially:
use cube_helix::CubeHelix; // Override 'start' and 'rotation' values let ch = CubeHelix { start: 0.2, rotations: 1.5, ..Default::default() }; // Returns color black: (0,0,0) let color = ch.get_color(0.0); assert_eq!(color.0, 0); assert_eq!(color.1, 0); assert_eq!(color.2, 0);
Fields
gamma: f64
Gamma factor.
start: f64
Starting angle: 0.5 -> purple
rotations: f64
Rotations (1.5 : R -> G -> B -> R).
Negative value will 'spin' in opposite direction.
saturation: f64
Value from 0..1 to control saturation. Zero value is completelly grayscale.
min: f64
Lowest value in value range. This value represents black.
max: f64
Highest value in value range. This value represents white.
Methods
impl CubeHelix
[src]
Adds color calculation to CubeHelix struct
pub fn get_color(&self, value: f64) -> (u8, u8, u8)
[src]
Calculates CubeHelix color for given value.
Value must be in the min..max range.
Returns a tuple with three values: (red: u8, green: u8, blue: u8).
Examples
use cube_helix::CubeHelix; // Use range 0..100 - defalts otherwise let ch = CubeHelix { min: 0.0, max: 100.0, ..Default::default() }; // Get color in the middle. Returns color: (174,97,158) let color = ch.get_color(50.0); assert_eq!(color.0, 174); assert_eq!(color.1, 97); assert_eq!(color.2, 158);
Trait Implementations
impl Default for CubeHelix
[src]
Default values to produce the same gradient as D.A Green's paper in Figure 1.
gamma: 1.0
start: 0.5
rotations: -1.5
saturation: 1.0
min: 0.0
max: 1.0
impl Debug for CubeHelix
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,