Skip to main content

SpanGradient

Struct SpanGradient 

Source
pub struct SpanGradient<'a, G, F> { /* private fields */ }
Expand description

Main gradient span generator.

Combines an interpolator (for coordinate transformation), a gradient function (for shape), and a color function (for color lookup) to produce gradient-colored pixel spans.

Port of C++ span_gradient<ColorT, Interpolator, GradientF, ColorF>.

Implementations§

Source§

impl<'a, G: GradientFunction, F: ColorFunction> SpanGradient<'a, G, F>

Source

pub fn new( interpolator: SpanInterpolatorLinear, gradient_function: G, color_function: &'a F, d1: f64, d2: f64, ) -> Self

Source

pub fn interpolator(&self) -> &SpanInterpolatorLinear

Source

pub fn interpolator_mut(&mut self) -> &mut SpanInterpolatorLinear

Source

pub fn gradient_function(&self) -> &G

Source

pub fn color_function(&self) -> &F

Source

pub fn d1(&self) -> f64

Source

pub fn d2(&self) -> f64

Source

pub fn set_d1(&mut self, v: f64)

Source

pub fn set_d2(&mut self, v: f64)

Trait Implementations§

Source§

impl<'a, G, F> SpanGenerator for SpanGradient<'a, G, F>

Source§

type Color = <F as ColorFunction>::Color

Source§

fn prepare(&mut self)

Called once before rendering begins.
Source§

fn generate(&mut self, span: &mut [F::Color], x: i32, y: i32, len: u32)

Generate colors for a horizontal span. Read more

Auto Trait Implementations§

§

impl<'a, G, F> Freeze for SpanGradient<'a, G, F>
where G: Freeze,

§

impl<'a, G, F> RefUnwindSafe for SpanGradient<'a, G, F>

§

impl<'a, G, F> Send for SpanGradient<'a, G, F>
where G: Send, F: Sync,

§

impl<'a, G, F> Sync for SpanGradient<'a, G, F>
where G: Sync, F: Sync,

§

impl<'a, G, F> Unpin for SpanGradient<'a, G, F>
where G: Unpin,

§

impl<'a, G, F> UnwindSafe for SpanGradient<'a, G, F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.