Struct qrcode::canvas::Canvas

source ·
pub struct Canvas { /* private fields */ }
Expand description

Canvas is an intermediate helper structure to render error-corrected data into a QR code.

Implementations§

source§

impl Canvas

source

pub fn new(version: Version, ec_level: EcLevel) -> Self

Constructs a new canvas big enough for a QR code of the given version.

source

pub fn get(&self, x: i16, y: i16) -> Module

Obtains a module at the given coordinates. For convenience, negative coordinates will wrap around.

source

pub fn get_mut(&mut self, x: i16, y: i16) -> &mut Module

Obtains a mutable module at the given coordinates. For convenience, negative coordinates will wrap around.

source

pub fn put(&mut self, x: i16, y: i16, color: Color)

Sets the color of a functional module at the given coordinates. For convenience, negative coordinates will wrap around.

source§

impl Canvas

source

pub fn draw_all_functional_patterns(&mut self)

Draw all functional patterns, before data placement.

All functional patterns (e.g. the finder pattern) except the format info pattern will be filled in. The format info pattern will be filled with light modules instead. Data bits can then put in the empty modules. with .draw_data().

source§

impl Canvas

source

pub fn draw_data(&mut self, data: &[u8], ec: &[u8])

Draws the encoded data and error correction codes to the empty modules.

source§

impl Canvas

source

pub fn apply_mask(&mut self, pattern: MaskPattern)

Applies a mask to the canvas. This method will also draw the format info patterns.

source§

impl Canvas

source

pub fn apply_best_mask(&self) -> Self

Construct a new canvas and apply the best masking that gives the lowest penalty score.

source

pub fn to_bools(&self) -> Vec<bool>

👎Deprecated since 0.4.0: use into_colors() instead

Convert the modules into a vector of booleans.

source

pub fn into_colors(self) -> Vec<Color>

Convert the modules into a vector of colors.

Trait Implementations§

source§

impl Clone for Canvas

source§

fn clone(&self) -> Canvas

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Canvas

§

impl RefUnwindSafe for Canvas

§

impl Send for Canvas

§

impl Sync for Canvas

§

impl Unpin for Canvas

§

impl UnwindSafe for Canvas

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.