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
impl Canvas
Sourcepub fn new(version: Version, ec_level: EcLevel) -> Self
pub fn new(version: Version, ec_level: EcLevel) -> Self
Constructs a new canvas big enough for a QR code of the given version.
Sourcepub fn get(&self, x: i16, y: i16) -> Module
pub fn get(&self, x: i16, y: i16) -> Module
Obtains a module at the given coordinates. For convenience, negative coordinates will wrap around.
Source§impl Canvas
impl Canvas
Sourcepub fn draw_all_functional_patterns(&mut self)
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
impl Canvas
Sourcepub fn apply_mask(&mut self, pattern: MaskPattern)
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
impl Canvas
Sourcepub fn apply_best_mask(&self) -> Self
pub fn apply_best_mask(&self) -> Self
Construct a new canvas and apply the best masking that gives the lowest penalty score.
Sourcepub fn apply_best_mask_with_pattern(&self) -> (Self, MaskPattern)
pub fn apply_best_mask_with_pattern(&self) -> (Self, MaskPattern)
Construct a new canvas with the best mask and return the selected mask pattern alongside it.
Sourcepub fn apply_best_mask_with_score(&self) -> (Self, MaskPattern, u16)
pub fn apply_best_mask_with_score(&self) -> (Self, MaskPattern, u16)
Construct a new canvas with the best mask and return the selected mask pattern and its penalty score.
Masks are compared using full u32 scores. Unusually high scores exceeding
u16::MAX are clipped to u16::MAX in the returned score.
Sourcepub fn into_colors(self) -> Vec<Color>
pub fn into_colors(self) -> Vec<Color>
Convert the modules into a vector of colors.