[][src]Struct footile::Raster

pub struct Raster<F: PixFmt> { /* fields omitted */ }

A raster image with owned pixel data. If the pixel data must be owned elsewhere, consider using RasterB.


use footile::{PathBuilder,Plotter,Raster,Rgba8};
let path = PathBuilder::new().pen_width(5.0)
                       .move_to(16.0, 48.0)
                       .line_to(32.0, 0.0)
                       .line_to(-16.0, -32.0)
let mut p = Plotter::new(100, 100);
let mut r = Raster::new(p.width(), p.height());
r.over(p.stroke(&path), Rgba8::rgb(208, 255, 208));


impl<F: PixFmt> Raster<F>[src]

pub fn new(width: u32, height: u32) -> Raster<F>[src]

Create a new raster image.

  • F Pixel format.
  • width Width in pixels.
  • height Height in pixels.

pub fn width(&self) -> u32[src]

Get raster width.

pub fn height(&self) -> u32[src]

Get raster height.

pub fn as_slice(&self) -> &[F][src]

Get the pixels as a slice.

pub fn as_slice_mut(&mut self) -> &mut [F][src]

Get the pixels as a mutable slice.

pub fn as_u8_slice(&self) -> &[u8][src]

Get the pixels as a u8 slice.

pub fn as_u8_slice_mut(&mut self) -> &mut [u8][src]

Get the pixels as a mutable u8 slice.

pub fn clear(&mut self)[src]

Clear all pixels.

pub fn over(&mut self, mask: &mut Mask, clr: F)[src]

Blend pixels with an alpha mask.

  • mask Alpha mask for compositing. It is cleared before returning.
  • clr Color to composite.
  • pixels Borrowed pixel data.

pub fn write_png(self, filename: &str) -> Result<()>[src]

Write the raster to a PNG (portable network graphics) file.

  • filename Name of file to write.

Auto Trait Implementations

impl<F> Send for Raster<F> where
    F: Send

impl<F> Sync for Raster<F> where
    F: Sync

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

The type returned in the event of a conversion error.

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