Function image::imageops::vertical_gradient[][src]

pub fn vertical_gradient<S, P, I>(img: &mut I, start: &P, stop: &P) where
    I: GenericImage<Pixel = P>,
    P: Pixel<Subpixel = S> + 'static,
    S: Primitive + Lerp + 'static, 

Fill the image with a linear vertical gradient

This function assumes a linear color space.

Examples

use image::{Rgba, RgbaImage, Pixel};
 
fn main() {
    let mut img = RgbaImage::new(100, 100);
    let start = Rgba::from_slice(&[0, 128, 0, 0]);
    let end = Rgba::from_slice(&[255, 255, 255, 255]);
 
    image::imageops::vertical_gradient(&mut img, start, end);
    img.save("vertical_gradient.png").unwrap();
}