Trait qrcode::render::Canvas

source ·
pub trait Canvas: Sized {
    type Pixel: Sized;
    type Image: Sized;

    // Required methods
    fn new(
        width: u32,
        height: u32,
        dark_pixel: Self::Pixel,
        light_pixel: Self::Pixel
    ) -> Self;
    fn draw_dark_pixel(&mut self, x: u32, y: u32);
    fn into_image(self) -> Self::Image;

    // Provided method
    fn draw_dark_rect(&mut self, left: u32, top: u32, width: u32, height: u32) { ... }
}
Expand description

Rendering canvas of a QR code image.

Required Associated Types§

Required Methods§

source

fn new( width: u32, height: u32, dark_pixel: Self::Pixel, light_pixel: Self::Pixel ) -> Self

Constructs a new canvas of the given dimensions.

source

fn draw_dark_pixel(&mut self, x: u32, y: u32)

Draws a single dark pixel at the (x, y) coordinate.

source

fn into_image(self) -> Self::Image

Finalize the canvas to a real image.

Provided Methods§

source

fn draw_dark_rect(&mut self, left: u32, top: u32, width: u32, height: u32)

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<P: Pixel + 'static> Canvas for (P, ImageBuffer<P, Vec<P::Subpixel>>)

§

type Pixel = P

§

type Image = ImageBuffer<P, Vec<<P as Pixel>::Subpixel>>

source§

fn new(width: u32, height: u32, dark_pixel: P, light_pixel: P) -> Self

source§

fn draw_dark_pixel(&mut self, x: u32, y: u32)

source§

fn into_image(self) -> ImageBuffer<P, Vec<P::Subpixel>>

Implementors§