Struct palette::gradient::Gradient [] [src]

pub struct Gradient<C: Mix + Clone>(_);

A linear interpolation between colors.

It's used to smoothly transition between a series of colors, that can be either evenly spaced or have customized positions. The gradient is continuous between the control points, but it's possible to iterate over a number of evenly spaced points using the take method. Any point outside the domain of the gradient will have the same color as the closest control point.

Methods

impl<C: Mix + Clone> Gradient<C>
[src]

fn new<I: IntoIterator<Item=C>>(colors: I) -> Gradient<C>

Create a gradient of evenly spaced colors with the domain [0.0, 1.0]. There must be at least one color.

fn with_domain(colors: Vec<(C::Scalar, C)>) -> Gradient<C>

Create a gradient of colors with custom spacing and domain. There must be at least one color and they are expected to be ordered by their position value.

fn get(&self, i: C::Scalar) -> C

Get a color from the gradient. The color of the closest control point will be returned if i is outside the domain.

fn take(&self, n: usize) -> Take<C>

Take n evenly spaced colors from the gradient, as an iterator.

fn slice<R: Into<Range<C::Scalar>>>(&self, range: R) -> Slice<C>

Slice this gradient to limit its domain.

fn domain(&self) -> (C::Scalar, C::Scalar)

Get the limits of this gradient's domain.

Trait Implementations

impl<C: Debug + Mix + Clone> Debug for Gradient<C> where C::Scalar: Debug
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<C: Clone + Mix + Clone> Clone for Gradient<C> where C::Scalar: Clone
[src]

fn clone(&self) -> Gradient<C>

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more