Trait agg::PixelDraw

source ·
pub trait PixelDraw: Pixel {
    fn fill<C: Color>(&mut self, color: C) { ... }
    fn copy_or_blend_pix<C: Color>(&mut self, id: (usize, usize), color: C) { ... }
    fn copy_or_blend_pix_with_cover<C: Color>(
        &mut self,
        id: (usize, usize),
        color: C,
        cover: u64
    ) { ... } fn blend_hline<C: Color>(
        &mut self,
        x: i64,
        y: i64,
        len: i64,
        color: C,
        cover: u64
    ) { ... } fn blend_solid_hspan<C: Color>(
        &mut self,
        x: i64,
        y: i64,
        len: i64,
        color: C,
        covers: &[u64]
    ) { ... } fn blend_vline<C: Color>(&mut self, x: i64, y: i64, len: i64, c: C, cover: u64) { ... } fn blend_solid_vspan<C: Color>(
        &mut self,
        x: i64,
        y: i64,
        len: i64,
        c: C,
        covers: &[u64]
    ) { ... } fn blend_color_hspan<C: Color>(
        &mut self,
        x: i64,
        y: i64,
        len: i64,
        colors: &[C],
        covers: &[u64],
        cover: u64
    ) { ... } fn blend_color_vspan<C: Color>(
        &mut self,
        x: i64,
        y: i64,
        len: i64,
        colors: &[C],
        covers: &[u64],
        cover: u64
    ) { ... } }

Provided Methods

Fill the data with the specified color

Copy or blend a pixel at id with color

If color is_opaque, the color is copied directly to the pixel, otherwise the color is blended with the pixel at id

If color is_transparent nothing is done

Copy or blend a pixel at id with color and a cover

If color is_opaque and cover equals cover_mask then the color is copied to the pixel at id', otherwise the coloris blended with the pixel atid’ considering the amount of cover

If color is_transparent nothing is done

use agg::{Source,Pixfmt,Rgb8,Rgba8,PixelDraw};

let mut pix = Pixfmt::<Rgb8>::new(1,1);
let black  = Rgba8::black();
let white  = Rgba8::white();
pix.copy_pixel(0,0,black);
assert_eq!(pix.get((0,0)), black);

let (alpha, cover) = (255, 255); // Copy Pixel
let color = Rgba8::new(255,255,255,alpha);
pix.copy_or_blend_pix_with_cover((0,0), color, cover);
assert_eq!(pix.get((0,0)), white);

let (alpha, cover) = (255, 128); // Partial Coverage, Blend
let color = Rgba8::new(255,255,255,alpha);
pix.copy_pixel(0,0,black);
pix.copy_or_blend_pix_with_cover((0,0), color, cover);
assert_eq!(pix.get((0,0)), Rgba8::new(128,128,128,255));

let (alpha, cover) = (128, 255); // Partial Coverage, Blend
let color = Rgba8::new(255,255,255,alpha);
pix.copy_pixel(0,0,black);
pix.copy_or_blend_pix_with_cover((0,0), color, cover);
assert_eq!(pix.get((0,0)), Rgba8::new(128,128,128,255));

Copy or Blend a single color from (x,y) to (x+len-1,y) with cover

Blend a single color from (x,y) to (x+len-1,y) with collection of covers

Copy or Blend a single color from (x,y) to (x,y+len-1) with cover

Blend a single color from (x,y) to (x,y+len-1) with collection of covers

Blend a collection of colors from (x,y) to (x+len-1,y) with either a collection of covers or a single cover

A collection of covers takes precedance over a single cover

Blend a collection of colors from (x,y) to (x,y+len-1) with either a collection of covers or a single cover

A collection of covers takes precedance over a single cover

Implementors