Skip to main content

Canvas

Trait 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§

Source

type Pixel: Sized

The pixel type stored in this canvas.

Source

type Image: Sized

The finalized image type produced from this canvas.

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)

Draws a filled dark rectangle covering the given module range. Default implementation fills it pixel by pixel; override for a faster path.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§