| 1 | //! The `canvas` module puts raw bits into the QR code canvas. |
| 2 | //! |
| 3 | //! use qrcode::types::{Version, EcLevel}; |
| 4 | //! use qrcode::canvas::{Canvas, MaskPattern}; |
| 5 | //! |
| 6 | //! let mut c = Canvas::new(Version::Normal(1), EcLevel::L); |
| 7 | //! c.draw_all_functional_patterns(); |
| 8 | //! c.draw_data(b"data_here", b"ec_code_here"); |
| 9 | //! c.apply_mask(MaskPattern::Checkerboard); |
| 10 | //! let bools = c.to_bools(); |
| 11 | |
| 12 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().; |
| 13 | |
| 14 | use craterust-analyzer cargo qrcode 0.14.1 crate/::castrust-analyzer cargo qrcode 0.14.1 cast/::Asrust-analyzer cargo qrcode 0.14.1 cast/As#; |
| 15 | use craterust-analyzer cargo qrcode 0.14.1 crate/::typesrust-analyzer cargo qrcode 0.14.1 types/::{Colorrust-analyzer cargo qrcode 0.14.1 types/Color#, EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#, Versionrust-analyzer cargo qrcode 0.14.1 types/Version#}; |
| 16 | |
| 17 | //------------------------------------------------------------------------------ |
| 18 | //{{{ Modules |
| 19 | |
| 20 | /// The color of a module (pixel) in the QR code. |
| 21 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 22 | pub enum Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module# { |
| 23 | /// The module is empty. |
| 24 | Emptyrust-analyzer cargo qrcode 0.14.1 canvas/Module#Empty#, |
| 25 | |
| 26 | /// The module is of functional patterns which cannot be masked, or pixels |
| 27 | /// which have been masked. |
| 28 | Maskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Masked#(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#), |
| 29 | |
| 30 | /// The module is of data and error correction bits before masking. |
| 31 | Unmaskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Unmasked#(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#), |
| 32 | } |
| 33 | |
| 34 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#> for Colorrust-analyzer cargo qrcode 0.14.1 types/Color# { |
| 35 | fn fromrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Color][`From<Module>`]from().(module: Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#) -> Selfrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Color][`From<Module>`] { |
| 36 | match module { |
| 37 | Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Emptyrust-analyzer cargo qrcode 0.14.1 canvas/Module#Empty# => Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 38 | Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Maskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Masked#(c) | Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Unmaskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Unmasked#(c) => c, |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | impl Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module# { |
| 44 | /// Checks whether a module is dark. |
| 45 | pub fn is_darkrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module]is_dark().(self) -> bool { |
| 46 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::fromrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Color][`From<Module>`]from().(self) rust-analyzer cargo qrcode 0.14.1 types/impl#[Color][`PartialEq<Self>`]eq().==rust-analyzer cargo qrcode 0.14.1 types/impl#[Color][`PartialEq<Self>`]eq(). rust-analyzer cargo qrcode 0.14.1 types/impl#[Color][`PartialEq<Self>`]eq().Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark# |
| 47 | } |
| 48 | |
| 49 | /// Apply a mask to the unmasked modules. |
| 50 | /// |
| 51 | /// use qrcode::canvas::Module; |
| 52 | /// use qrcode::types::Color; |
| 53 | /// |
| 54 | /// assert_eq!(Module::Unmasked(Color::Light).mask(true), Module::Masked(Color::Dark)); |
| 55 | /// assert_eq!(Module::Unmasked(Color::Dark).mask(true), Module::Masked(Color::Light)); |
| 56 | /// assert_eq!(Module::Unmasked(Color::Light).mask(false), Module::Masked(Color::Light)); |
| 57 | /// assert_eq!(Module::Masked(Color::Dark).mask(true), Module::Masked(Color::Dark)); |
| 58 | /// assert_eq!(Module::Masked(Color::Dark).mask(false), Module::Masked(Color::Dark)); |
| 59 | /// |
| 60 | #[must_use] |
| 61 | pub fn maskrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module]mask().(self, should_invert: bool) -> Selfrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module] { |
| 62 | match (self, should_invert) { |
| 63 | (Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Emptyrust-analyzer cargo qrcode 0.14.1 canvas/Module#Empty#, true) => Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Maskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Masked#(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#), |
| 64 | (Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Emptyrust-analyzer cargo qrcode 0.14.1 canvas/Module#Empty#, false) => Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Maskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Masked#(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#), |
| 65 | (Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Unmaskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Unmasked#(c), true) => Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Maskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Masked#(!rust-analyzer cargo qrcode 0.14.1 types/impl#[Color][Not]not().c), |
| 66 | (Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Unmaskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Unmasked#(c), false) | (Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Maskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Masked#(c), _) => Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Maskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Masked#(c), |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | //}}} |
| 72 | //------------------------------------------------------------------------------ |
| 73 | //{{{ Canvas |
| 74 | |
| 75 | /// `Canvas` is an intermediate helper structure to render error-corrected data |
| 76 | /// into a QR code. |
| 77 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 78 | pub struct Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas# { |
| 79 | /// The width and height of the canvas (cached as it is needed frequently). |
| 80 | widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width.: i16, |
| 81 | |
| 82 | /// The version of the QR code. |
| 83 | versionrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#version.: Versionrust-analyzer cargo qrcode 0.14.1 types/Version#, |
| 84 | |
| 85 | /// The error correction level of the QR code. |
| 86 | ec_levelrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#ec_level.: EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#, |
| 87 | |
| 88 | /// The modules of the QR code. Modules are arranged in left-to-right, then |
| 89 | /// top-to-bottom order. |
| 90 | modulesrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#modules.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#>, |
| 91 | } |
| 92 | |
| 93 | impl Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas# { |
| 94 | /// Constructs a new canvas big enough for a QR code of the given version. |
| 95 | pub fn newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(version: Versionrust-analyzer cargo qrcode 0.14.1 types/Version#, ec_level: EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#) -> Selfrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas] { |
| 96 | let width = version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(); |
| 97 | Selfrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas] { widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width., versionrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#version., ec_levelrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#ec_level., modulesrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#modules.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Emptyrust-analyzer cargo qrcode 0.14.1 canvas/Module#Empty#; (width *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul(). width).as_usizerust-analyzer cargo qrcode 0.14.1 cast/impl#[i16][As]as_usize().()] } |
| 98 | } |
| 99 | |
| 100 | /// Converts the canvas into a human-readable string. |
| 101 | #[cfg(test)] |
| 102 | fn to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 103 | let width = self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width.; |
| 104 | let mut res = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]with_capacity().((width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().(width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1)) as usize); |
| 105 | for y in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#width { |
| 106 | res.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('\n'); |
| 107 | for x in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#width { |
| 108 | res.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(match self.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(x, y) { |
| 109 | Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Emptyrust-analyzer cargo qrcode 0.14.1 canvas/Module#Empty# => '?', |
| 110 | Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Maskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Masked#(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#) => '.', |
| 111 | Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Maskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Masked#(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#) => '#', |
| 112 | Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Unmaskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Unmasked#(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#) => '-', |
| 113 | Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Unmaskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Unmasked#(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#) => '*', |
| 114 | }); |
| 115 | } |
| 116 | } |
| 117 | res |
| 118 | } |
| 119 | |
| 120 | fn coords_to_indexrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]coords_to_index().(&self, x: i16, y: i16) -> usize { |
| 121 | let x = if x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().0 { x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width. } else { x }.as_usizerust-analyzer cargo qrcode 0.14.1 cast/impl#[i16][As]as_usize().(); |
| 122 | let y = if y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().0 { y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width. } else { y }.as_usizerust-analyzer cargo qrcode 0.14.1 cast/impl#[i16][As]as_usize().(); |
| 123 | y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width..as_usizerust-analyzer cargo qrcode 0.14.1 cast/impl#[i16][As]as_usize().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().x |
| 124 | } |
| 125 | |
| 126 | /// Obtains a module at the given coordinates. For convenience, negative |
| 127 | /// coordinates will wrap around. |
| 128 | pub fn getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(&self, x: i16, y: i16) -> Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module# { |
| 129 | self.modulesrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#modules.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().self.coords_to_indexrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]coords_to_index().(x, y)]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). |
| 130 | } |
| 131 | |
| 132 | /// Obtains a mutable module at the given coordinates. For convenience, |
| 133 | /// negative coordinates will wrap around. |
| 134 | pub fn get_mutrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get_mut().(&mut self, x: i16, y: i16) -> &mut Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module# { |
| 135 | let index = self.coords_to_indexrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]coords_to_index().(x, y); |
| 136 | &mut self.modulesrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#modules.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().index]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). |
| 137 | } |
| 138 | |
| 139 | /// Sets the color of a functional module at the given coordinates. For |
| 140 | /// convenience, negative coordinates will wrap around. |
| 141 | pub fn putrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]put().(&mut self, x: i16, y: i16, color: Colorrust-analyzer cargo qrcode 0.14.1 types/Color#) { |
| 142 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self.get_mutrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get_mut().(x, y) = Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Maskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Masked#(color); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | #[cfg(test)] |
| 147 | mod basic_canvas_testsrust-analyzer cargo qrcode 0.14.1 canvas/basic_canvas_tests/ { |
| 148 | use craterust-analyzer cargo qrcode 0.14.1 crate/::canvasrust-analyzer cargo qrcode 0.14.1 canvas/::{Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#, Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#}; |
| 149 | use craterust-analyzer cargo qrcode 0.14.1 crate/::typesrust-analyzer cargo qrcode 0.14.1 types/::{Colorrust-analyzer cargo qrcode 0.14.1 types/Color#, EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#, Versionrust-analyzer cargo qrcode 0.14.1 types/Version#}; |
| 150 | |
| 151 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 152 | fn test_indexrust-analyzer cargo qrcode 0.14.1 canvas/basic_canvas_tests/test_index().() { |
| 153 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 154 | |
| 155 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(0, 4), Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Emptyrust-analyzer cargo qrcode 0.14.1 canvas/Module#Empty#); |
| 156 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().7), Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Emptyrust-analyzer cargo qrcode 0.14.1 canvas/Module#Empty#); |
| 157 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(21 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). 1, 21 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). 7), Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Emptyrust-analyzer cargo qrcode 0.14.1 canvas/Module#Empty#); |
| 158 | |
| 159 | c.putrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]put().(0, 0, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#); |
| 160 | c.putrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]put().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().7, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#); |
| 161 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(0, 0), Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Maskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Masked#(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#)); |
| 162 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(21 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). 1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().7), Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Maskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Masked#(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#)); |
| 163 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().1, 21 -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). 7), Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Maskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Masked#(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#)); |
| 164 | } |
| 165 | |
| 166 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 167 | fn test_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/basic_canvas_tests/test_debug_str().() { |
| 168 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 169 | |
| 170 | for i in 3_i16..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#20 { |
| 171 | for j in 3_i16..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#20 { |
| 172 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().c.get_mutrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get_mut().(i, j) = match ((i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().3) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`BitXor<Self>`]bitxor().^rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`BitXor<Self>`]bitxor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`BitXor<Self>`]bitxor().j) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().5 { |
| 173 | 0 => Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Emptyrust-analyzer cargo qrcode 0.14.1 canvas/Module#Empty#, |
| 174 | 1 => Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Maskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Masked#(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#), |
| 175 | 2 => Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Maskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Masked#(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#), |
| 176 | 3 => Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Unmaskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Unmasked#(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#), |
| 177 | 4 => Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Unmaskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Unmasked#(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#), |
| 178 | _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(), |
| 179 | }; |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 184 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 185 | "\n\ |
| 186 | ?????????????????????\n\ |
| 187 | ?????????????????????\n\ |
| 188 | ?????????????????????\n\ |
| 189 | ?????####****....---?\n\ |
| 190 | ???--.##-..##?..#??.?\n\ |
| 191 | ???#*?-.*?#.-*#?-*.??\n\ |
| 192 | ?????*?*?****-*-*---?\n\ |
| 193 | ???*.-.-.-?-?#?#?#*#?\n\ |
| 194 | ???.*#.*.*#.*#*#.*#*?\n\ |
| 195 | ?????.#-#--??.?.#---?\n\ |
| 196 | ???-.?*.-#?-.?#*-#?.?\n\ |
| 197 | ???##*??*..##*--*..??\n\ |
| 198 | ?????-???--??---?---?\n\ |
| 199 | ???*.#.*.#**.#*#.#*#?\n\ |
| 200 | ???##.-##..##..?#..??\n\ |
| 201 | ???.-?*.-?#.-?#*-?#*?\n\ |
| 202 | ????-.#?-.**#?-.#?-.?\n\ |
| 203 | ???**?-**??--**?-**??\n\ |
| 204 | ???#?*?#?*#.*-.-*-.-?\n\ |
| 205 | ???..-...--??###?###?\n\ |
| 206 | ?????????????????????" |
| 207 | ); |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | //}}} |
| 212 | //------------------------------------------------------------------------------ |
| 213 | //{{{ Finder patterns |
| 214 | |
| 215 | impl Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas# { |
| 216 | /// Draws a single finder pattern with the center at (x, y). |
| 217 | fn draw_finder_pattern_atrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_finder_pattern_at().(&mut self, x: i16, y: i16) { |
| 218 | let (dx_left, dx_right) = if x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().0 { (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().3, 4) } else { (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().4, 3) }; |
| 219 | let (dy_top, dy_bottom) = if y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().0 { (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().3, 4) } else { (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().4, 3) }; |
| 220 | for j in dy_top..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#dy_bottom { |
| 221 | for i in dx_left..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#dx_right { |
| 222 | self.putrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]put().( |
| 223 | x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().i, |
| 224 | y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().j, |
| 225 | #[allow(clippy::match_same_arms)] |
| 226 | match (i, j) { |
| 227 | (4 | -4, _) | (_, 4 | -4) => Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 228 | (3 | -3, _) | (_, 3 | -3) => Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 229 | (2 | -2, _) | (_, 2 | -2) => Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 230 | _ => Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 231 | }, |
| 232 | ); |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | /// Draws the finder patterns. |
| 238 | /// |
| 239 | /// The finder patterns is are 7×7 square patterns appearing at the three |
| 240 | /// corners of a QR code. They allows scanner to locate the QR code and |
| 241 | /// determine the orientation. |
| 242 | fn draw_finder_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_finder_patterns().(&mut self) { |
| 243 | self.draw_finder_pattern_atrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_finder_pattern_at().(3, 3); |
| 244 | |
| 245 | match self.versionrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#version. { |
| 246 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(_) => {} |
| 247 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(_) => { |
| 248 | self.draw_finder_pattern_atrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_finder_pattern_at().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().4, 3); |
| 249 | self.draw_finder_pattern_atrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_finder_pattern_at().(3, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().4); |
| 250 | } |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | #[cfg(test)] |
| 256 | mod finder_pattern_testsrust-analyzer cargo qrcode 0.14.1 canvas/finder_pattern_tests/ { |
| 257 | use craterust-analyzer cargo qrcode 0.14.1 crate/::canvasrust-analyzer cargo qrcode 0.14.1 canvas/::Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#; |
| 258 | use craterust-analyzer cargo qrcode 0.14.1 crate/::typesrust-analyzer cargo qrcode 0.14.1 types/::{EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#, Versionrust-analyzer cargo qrcode 0.14.1 types/Version#}; |
| 259 | |
| 260 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 261 | fn test_qrrust-analyzer cargo qrcode 0.14.1 canvas/finder_pattern_tests/test_qr().() { |
| 262 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 263 | c.draw_finder_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_finder_patterns().(); |
| 264 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 265 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 266 | "\n\ |
| 267 | #######.?????.#######\n\ |
| 268 | #.....#.?????.#.....#\n\ |
| 269 | #.###.#.?????.#.###.#\n\ |
| 270 | #.###.#.?????.#.###.#\n\ |
| 271 | #.###.#.?????.#.###.#\n\ |
| 272 | #.....#.?????.#.....#\n\ |
| 273 | #######.?????.#######\n\ |
| 274 | ........?????........\n\ |
| 275 | ?????????????????????\n\ |
| 276 | ?????????????????????\n\ |
| 277 | ?????????????????????\n\ |
| 278 | ?????????????????????\n\ |
| 279 | ?????????????????????\n\ |
| 280 | ........?????????????\n\ |
| 281 | #######.?????????????\n\ |
| 282 | #.....#.?????????????\n\ |
| 283 | #.###.#.?????????????\n\ |
| 284 | #.###.#.?????????????\n\ |
| 285 | #.###.#.?????????????\n\ |
| 286 | #.....#.?????????????\n\ |
| 287 | #######.?????????????" |
| 288 | ); |
| 289 | } |
| 290 | |
| 291 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 292 | fn test_micro_qrrust-analyzer cargo qrcode 0.14.1 canvas/finder_pattern_tests/test_micro_qr().() { |
| 293 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 294 | c.draw_finder_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_finder_patterns().(); |
| 295 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 296 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 297 | "\n\ |
| 298 | #######.???\n\ |
| 299 | #.....#.???\n\ |
| 300 | #.###.#.???\n\ |
| 301 | #.###.#.???\n\ |
| 302 | #.###.#.???\n\ |
| 303 | #.....#.???\n\ |
| 304 | #######.???\n\ |
| 305 | ........???\n\ |
| 306 | ???????????\n\ |
| 307 | ???????????\n\ |
| 308 | ???????????" |
| 309 | ); |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | //}}} |
| 314 | //------------------------------------------------------------------------------ |
| 315 | //{{{ Alignment patterns |
| 316 | |
| 317 | impl Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas# { |
| 318 | /// Draws a alignment pattern with the center at (x, y). |
| 319 | fn draw_alignment_pattern_atrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_alignment_pattern_at().(&mut self, x: i16, y: i16) { |
| 320 | if self.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(x, y) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Emptyrust-analyzer cargo qrcode 0.14.1 canvas/Module#Empty# { |
| 321 | return; |
| 322 | } |
| 323 | for j in -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().2..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#2 { |
| 324 | for i in -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().2..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#2 { |
| 325 | self.putrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]put().( |
| 326 | x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().i, |
| 327 | y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().j, |
| 328 | match (i, j) { |
| 329 | (2 | -2, _) | (_, 2 | -2) | (0, 0) => Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 330 | _ => Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 331 | }, |
| 332 | ); |
| 333 | } |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | /// Draws the alignment patterns. |
| 338 | /// |
| 339 | /// The alignment patterns are 5×5 square patterns inside the QR code symbol |
| 340 | /// to help the scanner create the square grid. |
| 341 | fn draw_alignment_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_alignment_patterns().(&mut self) { |
| 342 | match self.versionrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#version. { |
| 343 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(_) | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1) => {} |
| 344 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(2..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#6) => self.draw_alignment_pattern_atrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_alignment_pattern_at().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().7, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().7), |
| 345 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(a) => { |
| 346 | let positions = ALIGNMENT_PATTERN_POSITIONSrust-analyzer cargo qrcode 0.14.1 canvas/ALIGNMENT_PATTERN_POSITIONS.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().(a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().7).as_usizerust-analyzer cargo qrcode 0.14.1 cast/impl#[i16][As]as_usize().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().; |
| 347 | for x in positions { |
| 348 | for y in positions { |
| 349 | self.draw_alignment_pattern_atrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_alignment_pattern_at().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().x, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().y); |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | #[cfg(test)] |
| 358 | mod alignment_pattern_testsrust-analyzer cargo qrcode 0.14.1 canvas/alignment_pattern_tests/ { |
| 359 | use craterust-analyzer cargo qrcode 0.14.1 crate/::canvasrust-analyzer cargo qrcode 0.14.1 canvas/::Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#; |
| 360 | use craterust-analyzer cargo qrcode 0.14.1 crate/::typesrust-analyzer cargo qrcode 0.14.1 types/::{EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#, Versionrust-analyzer cargo qrcode 0.14.1 types/Version#}; |
| 361 | |
| 362 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 363 | fn test_draw_alignment_patterns_1rust-analyzer cargo qrcode 0.14.1 canvas/alignment_pattern_tests/test_draw_alignment_patterns_1().() { |
| 364 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 365 | c.draw_finder_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_finder_patterns().(); |
| 366 | c.draw_alignment_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_alignment_patterns().(); |
| 367 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 368 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 369 | "\n\ |
| 370 | #######.?????.#######\n\ |
| 371 | #.....#.?????.#.....#\n\ |
| 372 | #.###.#.?????.#.###.#\n\ |
| 373 | #.###.#.?????.#.###.#\n\ |
| 374 | #.###.#.?????.#.###.#\n\ |
| 375 | #.....#.?????.#.....#\n\ |
| 376 | #######.?????.#######\n\ |
| 377 | ........?????........\n\ |
| 378 | ?????????????????????\n\ |
| 379 | ?????????????????????\n\ |
| 380 | ?????????????????????\n\ |
| 381 | ?????????????????????\n\ |
| 382 | ?????????????????????\n\ |
| 383 | ........?????????????\n\ |
| 384 | #######.?????????????\n\ |
| 385 | #.....#.?????????????\n\ |
| 386 | #.###.#.?????????????\n\ |
| 387 | #.###.#.?????????????\n\ |
| 388 | #.###.#.?????????????\n\ |
| 389 | #.....#.?????????????\n\ |
| 390 | #######.?????????????" |
| 391 | ); |
| 392 | } |
| 393 | |
| 394 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 395 | fn test_draw_alignment_patterns_3rust-analyzer cargo qrcode 0.14.1 canvas/alignment_pattern_tests/test_draw_alignment_patterns_3().() { |
| 396 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(3), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 397 | c.draw_finder_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_finder_patterns().(); |
| 398 | c.draw_alignment_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_alignment_patterns().(); |
| 399 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 400 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 401 | "\n\ |
| 402 | #######.?????????????.#######\n\ |
| 403 | #.....#.?????????????.#.....#\n\ |
| 404 | #.###.#.?????????????.#.###.#\n\ |
| 405 | #.###.#.?????????????.#.###.#\n\ |
| 406 | #.###.#.?????????????.#.###.#\n\ |
| 407 | #.....#.?????????????.#.....#\n\ |
| 408 | #######.?????????????.#######\n\ |
| 409 | ........?????????????........\n\ |
| 410 | ?????????????????????????????\n\ |
| 411 | ?????????????????????????????\n\ |
| 412 | ?????????????????????????????\n\ |
| 413 | ?????????????????????????????\n\ |
| 414 | ?????????????????????????????\n\ |
| 415 | ?????????????????????????????\n\ |
| 416 | ?????????????????????????????\n\ |
| 417 | ?????????????????????????????\n\ |
| 418 | ?????????????????????????????\n\ |
| 419 | ?????????????????????????????\n\ |
| 420 | ?????????????????????????????\n\ |
| 421 | ?????????????????????????????\n\ |
| 422 | ????????????????????#####????\n\ |
| 423 | ........????????????#...#????\n\ |
| 424 | #######.????????????#.#.#????\n\ |
| 425 | #.....#.????????????#...#????\n\ |
| 426 | #.###.#.????????????#####????\n\ |
| 427 | #.###.#.?????????????????????\n\ |
| 428 | #.###.#.?????????????????????\n\ |
| 429 | #.....#.?????????????????????\n\ |
| 430 | #######.?????????????????????" |
| 431 | ); |
| 432 | } |
| 433 | |
| 434 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 435 | fn test_draw_alignment_patterns_7rust-analyzer cargo qrcode 0.14.1 canvas/alignment_pattern_tests/test_draw_alignment_patterns_7().() { |
| 436 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(7), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 437 | c.draw_finder_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_finder_patterns().(); |
| 438 | c.draw_alignment_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_alignment_patterns().(); |
| 439 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 440 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 441 | "\n\ |
| 442 | #######.?????????????????????????????.#######\n\ |
| 443 | #.....#.?????????????????????????????.#.....#\n\ |
| 444 | #.###.#.?????????????????????????????.#.###.#\n\ |
| 445 | #.###.#.?????????????????????????????.#.###.#\n\ |
| 446 | #.###.#.????????????#####????????????.#.###.#\n\ |
| 447 | #.....#.????????????#...#????????????.#.....#\n\ |
| 448 | #######.????????????#.#.#????????????.#######\n\ |
| 449 | ........????????????#...#????????????........\n\ |
| 450 | ????????????????????#####????????????????????\n\ |
| 451 | ?????????????????????????????????????????????\n\ |
| 452 | ?????????????????????????????????????????????\n\ |
| 453 | ?????????????????????????????????????????????\n\ |
| 454 | ?????????????????????????????????????????????\n\ |
| 455 | ?????????????????????????????????????????????\n\ |
| 456 | ?????????????????????????????????????????????\n\ |
| 457 | ?????????????????????????????????????????????\n\ |
| 458 | ?????????????????????????????????????????????\n\ |
| 459 | ?????????????????????????????????????????????\n\ |
| 460 | ?????????????????????????????????????????????\n\ |
| 461 | ?????????????????????????????????????????????\n\ |
| 462 | ????#####???????????#####???????????#####????\n\ |
| 463 | ????#...#???????????#...#???????????#...#????\n\ |
| 464 | ????#.#.#???????????#.#.#???????????#.#.#????\n\ |
| 465 | ????#...#???????????#...#???????????#...#????\n\ |
| 466 | ????#####???????????#####???????????#####????\n\ |
| 467 | ?????????????????????????????????????????????\n\ |
| 468 | ?????????????????????????????????????????????\n\ |
| 469 | ?????????????????????????????????????????????\n\ |
| 470 | ?????????????????????????????????????????????\n\ |
| 471 | ?????????????????????????????????????????????\n\ |
| 472 | ?????????????????????????????????????????????\n\ |
| 473 | ?????????????????????????????????????????????\n\ |
| 474 | ?????????????????????????????????????????????\n\ |
| 475 | ?????????????????????????????????????????????\n\ |
| 476 | ?????????????????????????????????????????????\n\ |
| 477 | ?????????????????????????????????????????????\n\ |
| 478 | ????????????????????#####???????????#####????\n\ |
| 479 | ........????????????#...#???????????#...#????\n\ |
| 480 | #######.????????????#.#.#???????????#.#.#????\n\ |
| 481 | #.....#.????????????#...#???????????#...#????\n\ |
| 482 | #.###.#.????????????#####???????????#####????\n\ |
| 483 | #.###.#.?????????????????????????????????????\n\ |
| 484 | #.###.#.?????????????????????????????????????\n\ |
| 485 | #.....#.?????????????????????????????????????\n\ |
| 486 | #######.?????????????????????????????????????" |
| 487 | ); |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | /// `ALIGNMENT_PATTERN_POSITIONS` describes the x- and y-coordinates of the |
| 492 | /// center of the alignment patterns. Since the QR code is symmetric, only one |
| 493 | /// coordinate is needed. |
| 494 | static ALIGNMENT_PATTERN_POSITIONSrust-analyzer cargo qrcode 0.14.1 canvas/ALIGNMENT_PATTERN_POSITIONS.: [&[i16]; 34] = [ |
| 495 | &[6, 22, 38], |
| 496 | &[6, 24, 42], |
| 497 | &[6, 26, 46], |
| 498 | &[6, 28, 50], |
| 499 | &[6, 30, 54], |
| 500 | &[6, 32, 58], |
| 501 | &[6, 34, 62], |
| 502 | &[6, 26, 46, 66], |
| 503 | &[6, 26, 48, 70], |
| 504 | &[6, 26, 50, 74], |
| 505 | &[6, 30, 54, 78], |
| 506 | &[6, 30, 56, 82], |
| 507 | &[6, 30, 58, 86], |
| 508 | &[6, 34, 62, 90], |
| 509 | &[6, 28, 50, 72, 94], |
| 510 | &[6, 26, 50, 74, 98], |
| 511 | &[6, 30, 54, 78, 102], |
| 512 | &[6, 28, 54, 80, 106], |
| 513 | &[6, 32, 58, 84, 110], |
| 514 | &[6, 30, 58, 86, 114], |
| 515 | &[6, 34, 62, 90, 118], |
| 516 | &[6, 26, 50, 74, 98, 122], |
| 517 | &[6, 30, 54, 78, 102, 126], |
| 518 | &[6, 26, 52, 78, 104, 130], |
| 519 | &[6, 30, 56, 82, 108, 134], |
| 520 | &[6, 34, 60, 86, 112, 138], |
| 521 | &[6, 30, 58, 86, 114, 142], |
| 522 | &[6, 34, 62, 90, 118, 146], |
| 523 | &[6, 30, 54, 78, 102, 126, 150], |
| 524 | &[6, 24, 50, 76, 102, 128, 154], |
| 525 | &[6, 28, 54, 80, 106, 132, 158], |
| 526 | &[6, 32, 58, 84, 110, 136, 162], |
| 527 | &[6, 26, 54, 82, 110, 138, 166], |
| 528 | &[6, 30, 58, 86, 114, 142, 170], |
| 529 | ]; |
| 530 | |
| 531 | //}}} |
| 532 | //------------------------------------------------------------------------------ |
| 533 | //{{{ Timing patterns |
| 534 | |
| 535 | impl Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas# { |
| 536 | /// Draws a line from (x1, y1) to (x2, y2), inclusively. |
| 537 | /// |
| 538 | /// The line must be either horizontal or vertical, i.e. |
| 539 | /// `x1 == x2 || y1 == y2`. Additionally, the first coordinates must be less |
| 540 | /// then the second ones. |
| 541 | /// |
| 542 | /// On even coordinates, `color_even` will be plotted; on odd coordinates, |
| 543 | /// `color_odd` will be plotted instead. Thus the timing pattern can be |
| 544 | /// drawn using this method. |
| 545 | /// |
| 546 | fn draw_linerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_line().(&mut self, x1: i16, y1: i16, x2: i16, y2: i16, color_even: Colorrust-analyzer cargo qrcode 0.14.1 types/Color#, color_odd: Colorrust-analyzer cargo qrcode 0.14.1 types/Color#) { |
| 547 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(x1 == x2 || y1 == y2); |
| 548 | |
| 549 | if y1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().y2 { |
| 550 | // Horizontal line. |
| 551 | for x in x1..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#x2 { |
| 552 | self.putrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]put().(x, y1, if x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 { color_even } else { color_odd }); |
| 553 | } |
| 554 | } else { |
| 555 | // Vertical line. |
| 556 | for y in y1..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#y2 { |
| 557 | self.putrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]put().(x1, y, if y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 { color_even } else { color_odd }); |
| 558 | } |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | /// Draws the timing patterns. |
| 563 | /// |
| 564 | /// The timing patterns are checkboard-colored lines near the edge of the QR |
| 565 | /// code symbol, to establish the fine-grained module coordinates when |
| 566 | /// scanning. |
| 567 | fn draw_timing_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_timing_patterns().(&mut self) { |
| 568 | let width = self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width.; |
| 569 | let (y, x1, x2) = match self.versionrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#version. { |
| 570 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(_) => (0, 8, width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().1), |
| 571 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(_) => (6, 8, width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().9), |
| 572 | }; |
| 573 | self.draw_linerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_line().(x1, y, x2, y, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#); |
| 574 | self.draw_linerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_line().(y, x1, y, x2, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#); |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | #[cfg(test)] |
| 579 | mod timing_pattern_testsrust-analyzer cargo qrcode 0.14.1 canvas/timing_pattern_tests/ { |
| 580 | use craterust-analyzer cargo qrcode 0.14.1 crate/::canvasrust-analyzer cargo qrcode 0.14.1 canvas/::Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#; |
| 581 | use craterust-analyzer cargo qrcode 0.14.1 crate/::typesrust-analyzer cargo qrcode 0.14.1 types/::{EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#, Versionrust-analyzer cargo qrcode 0.14.1 types/Version#}; |
| 582 | |
| 583 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 584 | fn test_draw_timing_patterns_qrrust-analyzer cargo qrcode 0.14.1 canvas/timing_pattern_tests/test_draw_timing_patterns_qr().() { |
| 585 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 586 | c.draw_timing_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_timing_patterns().(); |
| 587 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 588 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 589 | "\n\ |
| 590 | ?????????????????????\n\ |
| 591 | ?????????????????????\n\ |
| 592 | ?????????????????????\n\ |
| 593 | ?????????????????????\n\ |
| 594 | ?????????????????????\n\ |
| 595 | ?????????????????????\n\ |
| 596 | ????????#.#.#????????\n\ |
| 597 | ?????????????????????\n\ |
| 598 | ??????#??????????????\n\ |
| 599 | ??????.??????????????\n\ |
| 600 | ??????#??????????????\n\ |
| 601 | ??????.??????????????\n\ |
| 602 | ??????#??????????????\n\ |
| 603 | ?????????????????????\n\ |
| 604 | ?????????????????????\n\ |
| 605 | ?????????????????????\n\ |
| 606 | ?????????????????????\n\ |
| 607 | ?????????????????????\n\ |
| 608 | ?????????????????????\n\ |
| 609 | ?????????????????????\n\ |
| 610 | ?????????????????????" |
| 611 | ); |
| 612 | } |
| 613 | |
| 614 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 615 | fn test_draw_timing_patterns_micro_qrrust-analyzer cargo qrcode 0.14.1 canvas/timing_pattern_tests/test_draw_timing_patterns_micro_qr().() { |
| 616 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 617 | c.draw_timing_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_timing_patterns().(); |
| 618 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 619 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 620 | "\n\ |
| 621 | ????????#.#\n\ |
| 622 | ???????????\n\ |
| 623 | ???????????\n\ |
| 624 | ???????????\n\ |
| 625 | ???????????\n\ |
| 626 | ???????????\n\ |
| 627 | ???????????\n\ |
| 628 | ???????????\n\ |
| 629 | #??????????\n\ |
| 630 | .??????????\n\ |
| 631 | #??????????" |
| 632 | ); |
| 633 | } |
| 634 | } |
| 635 | |
| 636 | //}}} |
| 637 | //------------------------------------------------------------------------------ |
| 638 | //{{{ Format info & Version info |
| 639 | |
| 640 | impl Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas# { |
| 641 | /// Draws a big-endian integer onto the canvas with the given coordinates. |
| 642 | /// |
| 643 | /// The 1 bits will be plotted with `on_color` and the 0 bits with |
| 644 | /// `off_color`. The coordinates will be extracted from the `coords` |
| 645 | /// iterator. It will start from the most significant bits first, so |
| 646 | /// *trailing* zeros will be ignored. |
| 647 | fn draw_numberrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_number().(&mut self, number: u32, bits: u32, on_color: Colorrust-analyzer cargo qrcode 0.14.1 types/Color#, off_color: Colorrust-analyzer cargo qrcode 0.14.1 types/Color#, coords: &[(i16, i16)]) { |
| 648 | let mut mask = 1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<Self>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<Self>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<Self>`]shl().(bits rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().1); |
| 649 | for &(x, y) in coords { |
| 650 | let color = if (mask rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().number) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().0 { off_color } else { on_color }; |
| 651 | self.putrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]put().(x, y, color); |
| 652 | mask rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`ShrAssign<i32>`]shr_assign().>>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`ShrAssign<i32>`]shr_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`ShrAssign<i32>`]shr_assign().1; |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | /// Draws the format info patterns for an encoded number. |
| 657 | fn draw_format_info_patterns_with_numberrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_format_info_patterns_with_number().(&mut self, format_info: u16) { |
| 658 | let format_info = u32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`From<u16>`]from().(format_info); |
| 659 | match self.versionrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#version. { |
| 660 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(_) => { |
| 661 | self.draw_numberrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_number().(format_info, 15, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, &FORMAT_INFO_COORDS_MICRO_QRrust-analyzer cargo qrcode 0.14.1 canvas/FORMAT_INFO_COORDS_MICRO_QR.); |
| 662 | } |
| 663 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(_) => { |
| 664 | self.draw_numberrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_number().(format_info, 15, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, &FORMAT_INFO_COORDS_QR_MAINrust-analyzer cargo qrcode 0.14.1 canvas/FORMAT_INFO_COORDS_QR_MAIN.); |
| 665 | self.draw_numberrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_number().(format_info, 15, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, &FORMAT_INFO_COORDS_QR_SIDErust-analyzer cargo qrcode 0.14.1 canvas/FORMAT_INFO_COORDS_QR_SIDE.); |
| 666 | self.putrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]put().(8, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().8, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#); // Dark module. |
| 667 | } |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | /// Reserves area to put in the format information. |
| 672 | fn draw_reserved_format_info_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_reserved_format_info_patterns().(&mut self) { |
| 673 | self.draw_format_info_patterns_with_numberrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_format_info_patterns_with_number().(0); |
| 674 | } |
| 675 | |
| 676 | /// Draws the version information patterns. |
| 677 | fn draw_version_info_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_version_info_patterns().(&mut self) { |
| 678 | match self.versionrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#version. { |
| 679 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(_) | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#6) => {} |
| 680 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(a) => { |
| 681 | let version_info = VERSION_INFOSrust-analyzer cargo qrcode 0.14.1 canvas/VERSION_INFOS.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().(a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().7).as_usizerust-analyzer cargo qrcode 0.14.1 cast/impl#[i16][As]as_usize().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().; |
| 682 | self.draw_numberrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_number().(version_info, 18, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, &VERSION_INFO_COORDS_BLrust-analyzer cargo qrcode 0.14.1 canvas/VERSION_INFO_COORDS_BL.); |
| 683 | self.draw_numberrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_number().(version_info, 18, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, &VERSION_INFO_COORDS_TRrust-analyzer cargo qrcode 0.14.1 canvas/VERSION_INFO_COORDS_TR.); |
| 684 | } |
| 685 | } |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | #[cfg(test)] |
| 690 | mod draw_version_info_testsrust-analyzer cargo qrcode 0.14.1 canvas/draw_version_info_tests/ { |
| 691 | use craterust-analyzer cargo qrcode 0.14.1 crate/::canvasrust-analyzer cargo qrcode 0.14.1 canvas/::Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#; |
| 692 | use craterust-analyzer cargo qrcode 0.14.1 crate/::typesrust-analyzer cargo qrcode 0.14.1 types/::{Colorrust-analyzer cargo qrcode 0.14.1 types/Color#, EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#, Versionrust-analyzer cargo qrcode 0.14.1 types/Version#}; |
| 693 | |
| 694 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 695 | fn test_draw_numberrust-analyzer cargo qrcode 0.14.1 canvas/draw_version_info_tests/test_draw_number().() { |
| 696 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 697 | c.draw_numberrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_number().(0b10101101, 8, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, &[(0, 0), (0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().1), (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().2, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().2), (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().2, 0)]); |
| 698 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 699 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 700 | "\n\ |
| 701 | #????????.?\n\ |
| 702 | ???????????\n\ |
| 703 | ???????????\n\ |
| 704 | ???????????\n\ |
| 705 | ???????????\n\ |
| 706 | ???????????\n\ |
| 707 | ???????????\n\ |
| 708 | ???????????\n\ |
| 709 | ???????????\n\ |
| 710 | ?????????#?\n\ |
| 711 | .??????????" |
| 712 | ); |
| 713 | } |
| 714 | |
| 715 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 716 | fn test_draw_version_info_1rust-analyzer cargo qrcode 0.14.1 canvas/draw_version_info_tests/test_draw_version_info_1().() { |
| 717 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 718 | c.draw_version_info_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_version_info_patterns().(); |
| 719 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 720 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 721 | "\n\ |
| 722 | ?????????????????????\n\ |
| 723 | ?????????????????????\n\ |
| 724 | ?????????????????????\n\ |
| 725 | ?????????????????????\n\ |
| 726 | ?????????????????????\n\ |
| 727 | ?????????????????????\n\ |
| 728 | ?????????????????????\n\ |
| 729 | ?????????????????????\n\ |
| 730 | ?????????????????????\n\ |
| 731 | ?????????????????????\n\ |
| 732 | ?????????????????????\n\ |
| 733 | ?????????????????????\n\ |
| 734 | ?????????????????????\n\ |
| 735 | ?????????????????????\n\ |
| 736 | ?????????????????????\n\ |
| 737 | ?????????????????????\n\ |
| 738 | ?????????????????????\n\ |
| 739 | ?????????????????????\n\ |
| 740 | ?????????????????????\n\ |
| 741 | ?????????????????????\n\ |
| 742 | ?????????????????????" |
| 743 | ); |
| 744 | } |
| 745 | |
| 746 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 747 | fn test_draw_version_info_7rust-analyzer cargo qrcode 0.14.1 canvas/draw_version_info_tests/test_draw_version_info_7().() { |
| 748 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(7), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 749 | c.draw_version_info_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_version_info_patterns().(); |
| 750 | |
| 751 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 752 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 753 | "\n\ |
| 754 | ??????????????????????????????????..#????????\n\ |
| 755 | ??????????????????????????????????.#.????????\n\ |
| 756 | ??????????????????????????????????.#.????????\n\ |
| 757 | ??????????????????????????????????.##????????\n\ |
| 758 | ??????????????????????????????????###????????\n\ |
| 759 | ??????????????????????????????????...????????\n\ |
| 760 | ?????????????????????????????????????????????\n\ |
| 761 | ?????????????????????????????????????????????\n\ |
| 762 | ?????????????????????????????????????????????\n\ |
| 763 | ?????????????????????????????????????????????\n\ |
| 764 | ?????????????????????????????????????????????\n\ |
| 765 | ?????????????????????????????????????????????\n\ |
| 766 | ?????????????????????????????????????????????\n\ |
| 767 | ?????????????????????????????????????????????\n\ |
| 768 | ?????????????????????????????????????????????\n\ |
| 769 | ?????????????????????????????????????????????\n\ |
| 770 | ?????????????????????????????????????????????\n\ |
| 771 | ?????????????????????????????????????????????\n\ |
| 772 | ?????????????????????????????????????????????\n\ |
| 773 | ?????????????????????????????????????????????\n\ |
| 774 | ?????????????????????????????????????????????\n\ |
| 775 | ?????????????????????????????????????????????\n\ |
| 776 | ?????????????????????????????????????????????\n\ |
| 777 | ?????????????????????????????????????????????\n\ |
| 778 | ?????????????????????????????????????????????\n\ |
| 779 | ?????????????????????????????????????????????\n\ |
| 780 | ?????????????????????????????????????????????\n\ |
| 781 | ?????????????????????????????????????????????\n\ |
| 782 | ?????????????????????????????????????????????\n\ |
| 783 | ?????????????????????????????????????????????\n\ |
| 784 | ?????????????????????????????????????????????\n\ |
| 785 | ?????????????????????????????????????????????\n\ |
| 786 | ?????????????????????????????????????????????\n\ |
| 787 | ?????????????????????????????????????????????\n\ |
| 788 | ....#.???????????????????????????????????????\n\ |
| 789 | .####.???????????????????????????????????????\n\ |
| 790 | #..##.???????????????????????????????????????\n\ |
| 791 | ?????????????????????????????????????????????\n\ |
| 792 | ?????????????????????????????????????????????\n\ |
| 793 | ?????????????????????????????????????????????\n\ |
| 794 | ?????????????????????????????????????????????\n\ |
| 795 | ?????????????????????????????????????????????\n\ |
| 796 | ?????????????????????????????????????????????\n\ |
| 797 | ?????????????????????????????????????????????\n\ |
| 798 | ?????????????????????????????????????????????" |
| 799 | ); |
| 800 | } |
| 801 | |
| 802 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 803 | fn test_draw_reserved_format_info_patterns_qrrust-analyzer cargo qrcode 0.14.1 canvas/draw_version_info_tests/test_draw_reserved_format_info_patterns_qr().() { |
| 804 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 805 | c.draw_reserved_format_info_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_reserved_format_info_patterns().(); |
| 806 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 807 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 808 | "\n\ |
| 809 | ????????.????????????\n\ |
| 810 | ????????.????????????\n\ |
| 811 | ????????.????????????\n\ |
| 812 | ????????.????????????\n\ |
| 813 | ????????.????????????\n\ |
| 814 | ????????.????????????\n\ |
| 815 | ?????????????????????\n\ |
| 816 | ????????.????????????\n\ |
| 817 | ......?..????........\n\ |
| 818 | ?????????????????????\n\ |
| 819 | ?????????????????????\n\ |
| 820 | ?????????????????????\n\ |
| 821 | ?????????????????????\n\ |
| 822 | ????????#????????????\n\ |
| 823 | ????????.????????????\n\ |
| 824 | ????????.????????????\n\ |
| 825 | ????????.????????????\n\ |
| 826 | ????????.????????????\n\ |
| 827 | ????????.????????????\n\ |
| 828 | ????????.????????????\n\ |
| 829 | ????????.????????????" |
| 830 | ); |
| 831 | } |
| 832 | |
| 833 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 834 | fn test_draw_reserved_format_info_patterns_micro_qrrust-analyzer cargo qrcode 0.14.1 canvas/draw_version_info_tests/test_draw_reserved_format_info_patterns_micro_qr().() { |
| 835 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 836 | c.draw_reserved_format_info_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_reserved_format_info_patterns().(); |
| 837 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 838 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 839 | "\n\ |
| 840 | ???????????\n\ |
| 841 | ????????.??\n\ |
| 842 | ????????.??\n\ |
| 843 | ????????.??\n\ |
| 844 | ????????.??\n\ |
| 845 | ????????.??\n\ |
| 846 | ????????.??\n\ |
| 847 | ????????.??\n\ |
| 848 | ?........??\n\ |
| 849 | ???????????\n\ |
| 850 | ???????????" |
| 851 | ); |
| 852 | } |
| 853 | } |
| 854 | |
| 855 | static VERSION_INFO_COORDS_BLrust-analyzer cargo qrcode 0.14.1 canvas/VERSION_INFO_COORDS_BL.: [(i16, i16); 18] = [ |
| 856 | (5, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().9), |
| 857 | (5, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().10), |
| 858 | (5, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().11), |
| 859 | (4, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().9), |
| 860 | (4, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().10), |
| 861 | (4, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().11), |
| 862 | (3, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().9), |
| 863 | (3, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().10), |
| 864 | (3, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().11), |
| 865 | (2, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().9), |
| 866 | (2, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().10), |
| 867 | (2, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().11), |
| 868 | (1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().9), |
| 869 | (1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().10), |
| 870 | (1, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().11), |
| 871 | (0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().9), |
| 872 | (0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().10), |
| 873 | (0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().11), |
| 874 | ]; |
| 875 | |
| 876 | static VERSION_INFO_COORDS_TRrust-analyzer cargo qrcode 0.14.1 canvas/VERSION_INFO_COORDS_TR.: [(i16, i16); 18] = [ |
| 877 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().9, 5), |
| 878 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().10, 5), |
| 879 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().11, 5), |
| 880 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().9, 4), |
| 881 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().10, 4), |
| 882 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().11, 4), |
| 883 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().9, 3), |
| 884 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().10, 3), |
| 885 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().11, 3), |
| 886 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().9, 2), |
| 887 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().10, 2), |
| 888 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().11, 2), |
| 889 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().9, 1), |
| 890 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().10, 1), |
| 891 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().11, 1), |
| 892 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().9, 0), |
| 893 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().10, 0), |
| 894 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().11, 0), |
| 895 | ]; |
| 896 | |
| 897 | static FORMAT_INFO_COORDS_QR_MAINrust-analyzer cargo qrcode 0.14.1 canvas/FORMAT_INFO_COORDS_QR_MAIN.: [(i16, i16); 15] = [ |
| 898 | (0, 8), |
| 899 | (1, 8), |
| 900 | (2, 8), |
| 901 | (3, 8), |
| 902 | (4, 8), |
| 903 | (5, 8), |
| 904 | (7, 8), |
| 905 | (8, 8), |
| 906 | (8, 7), |
| 907 | (8, 5), |
| 908 | (8, 4), |
| 909 | (8, 3), |
| 910 | (8, 2), |
| 911 | (8, 1), |
| 912 | (8, 0), |
| 913 | ]; |
| 914 | |
| 915 | static FORMAT_INFO_COORDS_QR_SIDErust-analyzer cargo qrcode 0.14.1 canvas/FORMAT_INFO_COORDS_QR_SIDE.: [(i16, i16); 15] = [ |
| 916 | (8, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().1), |
| 917 | (8, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().2), |
| 918 | (8, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().3), |
| 919 | (8, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().4), |
| 920 | (8, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().5), |
| 921 | (8, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().6), |
| 922 | (8, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().7), |
| 923 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().8, 8), |
| 924 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().7, 8), |
| 925 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().6, 8), |
| 926 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().5, 8), |
| 927 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().4, 8), |
| 928 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().3, 8), |
| 929 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().2, 8), |
| 930 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().1, 8), |
| 931 | ]; |
| 932 | |
| 933 | static FORMAT_INFO_COORDS_MICRO_QRrust-analyzer cargo qrcode 0.14.1 canvas/FORMAT_INFO_COORDS_MICRO_QR.: [(i16, i16); 15] = [ |
| 934 | (1, 8), |
| 935 | (2, 8), |
| 936 | (3, 8), |
| 937 | (4, 8), |
| 938 | (5, 8), |
| 939 | (6, 8), |
| 940 | (7, 8), |
| 941 | (8, 8), |
| 942 | (8, 7), |
| 943 | (8, 6), |
| 944 | (8, 5), |
| 945 | (8, 4), |
| 946 | (8, 3), |
| 947 | (8, 2), |
| 948 | (8, 1), |
| 949 | ]; |
| 950 | |
| 951 | static VERSION_INFOSrust-analyzer cargo qrcode 0.14.1 canvas/VERSION_INFOS.: [u32; 34] = [ |
| 952 | 0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, 0x0f928, 0x10b78, 0x1145d, 0x12a17, |
| 953 | 0x13532, 0x149a6, 0x15683, 0x168c9, 0x177ec, 0x18ec4, 0x191e1, 0x1afab, 0x1b08e, 0x1cc1a, 0x1d33f, 0x1ed75, |
| 954 | 0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b, 0x2542e, 0x26a64, 0x27541, 0x28c69, |
| 955 | ]; |
| 956 | |
| 957 | //}}} |
| 958 | //------------------------------------------------------------------------------ |
| 959 | //{{{ All functional patterns before data placement |
| 960 | |
| 961 | impl Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas# { |
| 962 | /// Draw all functional patterns, before data placement. |
| 963 | /// |
| 964 | /// All functional patterns (e.g. the finder pattern) *except* the format |
| 965 | /// info pattern will be filled in. The format info pattern will be filled |
| 966 | /// with light modules instead. Data bits can then put in the empty modules. |
| 967 | /// with `.draw_data()`. |
| 968 | pub fn draw_all_functional_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_all_functional_patterns().(&mut self) { |
| 969 | self.draw_finder_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_finder_patterns().(); |
| 970 | self.draw_alignment_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_alignment_patterns().(); |
| 971 | self.draw_reserved_format_info_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_reserved_format_info_patterns().(); |
| 972 | self.draw_timing_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_timing_patterns().(); |
| 973 | self.draw_version_info_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_version_info_patterns().(); |
| 974 | } |
| 975 | } |
| 976 | |
| 977 | /// Gets whether the module at the given coordinates represents a functional |
| 978 | /// module. |
| 979 | pub fn is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version: Versionrust-analyzer cargo qrcode 0.14.1 types/Version#, width: i16, x: i16, y: i16) -> bool { |
| 980 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(width == version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().()); |
| 981 | |
| 982 | let x = if x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().0 { x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().width } else { x }; |
| 983 | let y = if y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().0 { y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().width } else { y }; |
| 984 | |
| 985 | match version { |
| 986 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(_) => x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 || y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 || (x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().9 && y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().9), |
| 987 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(a) => { |
| 988 | let non_alignment_test = x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().6 || y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().6 || // Timing patterns |
| 989 | (x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().9 && y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().9) || // Top-left finder pattern |
| 990 | (x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().9 && y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().width-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().8) || // Bottom-left finder pattern |
| 991 | (x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().width-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().8 && y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().9); // Top-right finder pattern |
| 992 | match a { |
| 993 | _ if non_alignment_test => true, |
| 994 | 1 => false, |
| 995 | 2..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#6 => (width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().7 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().x).absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]abs().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().2 && (width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().7 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().y).absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]abs().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().2, |
| 996 | _ => { |
| 997 | let positions = ALIGNMENT_PATTERN_POSITIONSrust-analyzer cargo qrcode 0.14.1 canvas/ALIGNMENT_PATTERN_POSITIONS.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().(a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().7).as_usizerust-analyzer cargo qrcode 0.14.1 cast/impl#[i16][As]as_usize().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().; |
| 998 | let last = positions.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1; |
| 999 | for (i, align_x) in positions.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 1000 | for (j, align_y) in positions.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 1001 | if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 && (j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 || j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().last) || (i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().last && j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0) { |
| 1002 | continue; |
| 1003 | } |
| 1004 | if (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().align_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().x).absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]abs().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().2 && (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().align_y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().y).absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]abs().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().2 { |
| 1005 | return true; |
| 1006 | } |
| 1007 | } |
| 1008 | } |
| 1009 | false |
| 1010 | } |
| 1011 | } |
| 1012 | } |
| 1013 | } |
| 1014 | } |
| 1015 | |
| 1016 | #[cfg(test)] |
| 1017 | mod all_functional_patterns_testsrust-analyzer cargo qrcode 0.14.1 canvas/all_functional_patterns_tests/ { |
| 1018 | use craterust-analyzer cargo qrcode 0.14.1 crate/::canvasrust-analyzer cargo qrcode 0.14.1 canvas/::{is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional()., Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#}; |
| 1019 | use craterust-analyzer cargo qrcode 0.14.1 crate/::typesrust-analyzer cargo qrcode 0.14.1 types/::{EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#, Versionrust-analyzer cargo qrcode 0.14.1 types/Version#}; |
| 1020 | |
| 1021 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1022 | fn test_all_functional_patterns_qrrust-analyzer cargo qrcode 0.14.1 canvas/all_functional_patterns_tests/test_all_functional_patterns_qr().() { |
| 1023 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(2), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 1024 | c.draw_all_functional_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_all_functional_patterns().(); |
| 1025 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1026 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 1027 | "\n\ |
| 1028 | #######..????????.#######\n\ |
| 1029 | #.....#..????????.#.....#\n\ |
| 1030 | #.###.#..????????.#.###.#\n\ |
| 1031 | #.###.#..????????.#.###.#\n\ |
| 1032 | #.###.#..????????.#.###.#\n\ |
| 1033 | #.....#..????????.#.....#\n\ |
| 1034 | #######.#.#.#.#.#.#######\n\ |
| 1035 | .........????????........\n\ |
| 1036 | ......#..????????........\n\ |
| 1037 | ??????.??????????????????\n\ |
| 1038 | ??????#??????????????????\n\ |
| 1039 | ??????.??????????????????\n\ |
| 1040 | ??????#??????????????????\n\ |
| 1041 | ??????.??????????????????\n\ |
| 1042 | ??????#??????????????????\n\ |
| 1043 | ??????.??????????????????\n\ |
| 1044 | ??????#?????????#####????\n\ |
| 1045 | ........#???????#...#????\n\ |
| 1046 | #######..???????#.#.#????\n\ |
| 1047 | #.....#..???????#...#????\n\ |
| 1048 | #.###.#..???????#####????\n\ |
| 1049 | #.###.#..????????????????\n\ |
| 1050 | #.###.#..????????????????\n\ |
| 1051 | #.....#..????????????????\n\ |
| 1052 | #######..????????????????" |
| 1053 | ); |
| 1054 | } |
| 1055 | |
| 1056 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1057 | fn test_all_functional_patterns_micro_qrrust-analyzer cargo qrcode 0.14.1 canvas/all_functional_patterns_tests/test_all_functional_patterns_micro_qr().() { |
| 1058 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 1059 | c.draw_all_functional_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_all_functional_patterns().(); |
| 1060 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1061 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 1062 | "\n\ |
| 1063 | #######.#.#\n\ |
| 1064 | #.....#..??\n\ |
| 1065 | #.###.#..??\n\ |
| 1066 | #.###.#..??\n\ |
| 1067 | #.###.#..??\n\ |
| 1068 | #.....#..??\n\ |
| 1069 | #######..??\n\ |
| 1070 | .........??\n\ |
| 1071 | #........??\n\ |
| 1072 | .??????????\n\ |
| 1073 | #??????????" |
| 1074 | ); |
| 1075 | } |
| 1076 | |
| 1077 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1078 | fn test_is_functional_qr_1rust-analyzer cargo qrcode 0.14.1 canvas/all_functional_patterns_tests/test_is_functional_qr_1().() { |
| 1079 | let version = Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1); |
| 1080 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 0, 0)); |
| 1081 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 10, 6)); |
| 1082 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 10, 5)); |
| 1083 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 14, 14)); |
| 1084 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 6, 11)); |
| 1085 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 4, 11)); |
| 1086 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 4, 13)); |
| 1087 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 17, 7)); |
| 1088 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 17, 17)); |
| 1089 | } |
| 1090 | |
| 1091 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1092 | fn test_is_functional_qr_3rust-analyzer cargo qrcode 0.14.1 canvas/all_functional_patterns_tests/test_is_functional_qr_3().() { |
| 1093 | let version = Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(3); |
| 1094 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 0, 0)); |
| 1095 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 25, 24)); |
| 1096 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 24, 24)); |
| 1097 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 9, 25)); |
| 1098 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 20, 0)); |
| 1099 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 21, 0)); |
| 1100 | } |
| 1101 | |
| 1102 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1103 | fn test_is_functional_qr_7rust-analyzer cargo qrcode 0.14.1 canvas/all_functional_patterns_tests/test_is_functional_qr_7().() { |
| 1104 | let version = Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(7); |
| 1105 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 21, 4)); |
| 1106 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 7, 21)); |
| 1107 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 22, 22)); |
| 1108 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 8, 8)); |
| 1109 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 19, 5)); |
| 1110 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 36, 3)); |
| 1111 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 4, 36)); |
| 1112 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 38, 38)); |
| 1113 | } |
| 1114 | |
| 1115 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1116 | fn test_is_functional_microrust-analyzer cargo qrcode 0.14.1 canvas/all_functional_patterns_tests/test_is_functional_micro().() { |
| 1117 | let version = Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(1); |
| 1118 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 8, 0)); |
| 1119 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 10, 0)); |
| 1120 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 10, 1)); |
| 1121 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 8, 8)); |
| 1122 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 0, 9)); |
| 1123 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_functionalrust-analyzer cargo qrcode 0.14.1 canvas/is_functional().(version, version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(), 1, 9)); |
| 1124 | } |
| 1125 | } |
| 1126 | |
| 1127 | //}}} |
| 1128 | //------------------------------------------------------------------------------ |
| 1129 | //{{{ Data placement iterator |
| 1130 | |
| 1131 | struct DataModuleIterrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter# { |
| 1132 | xrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#x.: i16, |
| 1133 | yrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#y.: i16, |
| 1134 | widthrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#width.: i16, |
| 1135 | timing_pattern_columnrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#timing_pattern_column.: i16, |
| 1136 | } |
| 1137 | |
| 1138 | impl DataModuleIterrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter# { |
| 1139 | fn newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[DataModuleIter]new().(version: Versionrust-analyzer cargo qrcode 0.14.1 types/Version#) -> Selfrust-analyzer cargo qrcode 0.14.1 canvas/impl#[DataModuleIter] { |
| 1140 | let width = version.widthrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]width().(); |
| 1141 | Selfrust-analyzer cargo qrcode 0.14.1 canvas/impl#[DataModuleIter] { |
| 1142 | xrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#x.: width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().1, |
| 1143 | yrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#y.: width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().1, |
| 1144 | widthrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#width., |
| 1145 | timing_pattern_columnrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#timing_pattern_column.: match version { |
| 1146 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(_) => 0, |
| 1147 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(_) => 6, |
| 1148 | }, |
| 1149 | } |
| 1150 | } |
| 1151 | } |
| 1152 | |
| 1153 | impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for DataModuleIterrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter# { |
| 1154 | type Itemrust-analyzer cargo qrcode 0.14.1 canvas/impl#[DataModuleIter][Iterator]Item# = (i16, i16); |
| 1155 | |
| 1156 | fn nextrust-analyzer cargo qrcode 0.14.1 canvas/impl#[DataModuleIter][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(i16, i16)> { |
| 1157 | let adjusted_ref_col = if self.xrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().self.timing_pattern_columnrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#timing_pattern_column. { self.xrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1 } else { self.xrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#x. }; |
| 1158 | if adjusted_ref_col rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().0 { |
| 1159 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 1160 | } |
| 1161 | |
| 1162 | let res = (self.xrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#x., self.yrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#y.); |
| 1163 | let column_type = (self.widthrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#width. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().adjusted_ref_col) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().4; |
| 1164 | |
| 1165 | match column_type { |
| 1166 | 2 if self.yrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#y. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]gt().0 => { |
| 1167 | self.yrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#y. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`SubAssign<Self>`]sub_assign().1; |
| 1168 | self.xrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`AddAssign<Self>`]add_assign().1; |
| 1169 | } |
| 1170 | 0 if self.yrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#y. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().self.widthrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#width. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().1 => { |
| 1171 | self.yrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#y. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`AddAssign<Self>`]add_assign().1; |
| 1172 | self.xrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`AddAssign<Self>`]add_assign().1; |
| 1173 | } |
| 1174 | 0 | 2 if self.xrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().self.timing_pattern_columnrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#timing_pattern_column. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1 => { |
| 1175 | self.xrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`SubAssign<Self>`]sub_assign().2; |
| 1176 | } |
| 1177 | _ => { |
| 1178 | self.xrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`SubAssign<Self>`]sub_assign().1; |
| 1179 | } |
| 1180 | } |
| 1181 | |
| 1182 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(res) |
| 1183 | } |
| 1184 | } |
| 1185 | |
| 1186 | #[cfg(test)] |
| 1187 | #[rustfmt::skip] // skip to prevent file becoming too long. |
| 1188 | mod data_iter_testsrust-analyzer cargo qrcode 0.14.1 canvas/data_iter_tests/ { |
| 1189 | use craterust-analyzer cargo qrcode 0.14.1 crate/::canvasrust-analyzer cargo qrcode 0.14.1 canvas/::DataModuleIterrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#; |
| 1190 | use craterust-analyzer cargo qrcode 0.14.1 crate/::typesrust-analyzer cargo qrcode 0.14.1 types/::Versionrust-analyzer cargo qrcode 0.14.1 types/Version#; |
| 1191 | |
| 1192 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1193 | fn test_qrrust-analyzer cargo qrcode 0.14.1 canvas/data_iter_tests/test_qr().() { |
| 1194 | let res = DataModuleIterrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[DataModuleIter]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1)).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(i16, i16)>>(); |
| 1195 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(res, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 1196 | (20, 20), (19, 20), (20, 19), (19, 19), (20, 18), (19, 18), |
| 1197 | (20, 17), (19, 17), (20, 16), (19, 16), (20, 15), (19, 15), |
| 1198 | (20, 14), (19, 14), (20, 13), (19, 13), (20, 12), (19, 12), |
| 1199 | (20, 11), (19, 11), (20, 10), (19, 10), (20, 9), (19, 9), |
| 1200 | (20, 8), (19, 8), (20, 7), (19, 7), (20, 6), (19, 6), |
| 1201 | (20, 5), (19, 5), (20, 4), (19, 4), (20, 3), (19, 3), |
| 1202 | (20, 2), (19, 2), (20, 1), (19, 1), (20, 0), (19, 0), |
| 1203 | |
| 1204 | (18, 0), (17, 0), (18, 1), (17, 1), (18, 2), (17, 2), |
| 1205 | (18, 3), (17, 3), (18, 4), (17, 4), (18, 5), (17, 5), |
| 1206 | (18, 6), (17, 6), (18, 7), (17, 7), (18, 8), (17, 8), |
| 1207 | (18, 9), (17, 9), (18, 10), (17, 10), (18, 11), (17, 11), |
| 1208 | (18, 12), (17, 12), (18, 13), (17, 13), (18, 14), (17, 14), |
| 1209 | (18, 15), (17, 15), (18, 16), (17, 16), (18, 17), (17, 17), |
| 1210 | (18, 18), (17, 18), (18, 19), (17, 19), (18, 20), (17, 20), |
| 1211 | |
| 1212 | (16, 20), (15, 20), (16, 19), (15, 19), (16, 18), (15, 18), |
| 1213 | (16, 17), (15, 17), (16, 16), (15, 16), (16, 15), (15, 15), |
| 1214 | (16, 14), (15, 14), (16, 13), (15, 13), (16, 12), (15, 12), |
| 1215 | (16, 11), (15, 11), (16, 10), (15, 10), (16, 9), (15, 9), |
| 1216 | (16, 8), (15, 8), (16, 7), (15, 7), (16, 6), (15, 6), |
| 1217 | (16, 5), (15, 5), (16, 4), (15, 4), (16, 3), (15, 3), |
| 1218 | (16, 2), (15, 2), (16, 1), (15, 1), (16, 0), (15, 0), |
| 1219 | |
| 1220 | (14, 0), (13, 0), (14, 1), (13, 1), (14, 2), (13, 2), |
| 1221 | (14, 3), (13, 3), (14, 4), (13, 4), (14, 5), (13, 5), |
| 1222 | (14, 6), (13, 6), (14, 7), (13, 7), (14, 8), (13, 8), |
| 1223 | (14, 9), (13, 9), (14, 10), (13, 10), (14, 11), (13, 11), |
| 1224 | (14, 12), (13, 12), (14, 13), (13, 13), (14, 14), (13, 14), |
| 1225 | (14, 15), (13, 15), (14, 16), (13, 16), (14, 17), (13, 17), |
| 1226 | (14, 18), (13, 18), (14, 19), (13, 19), (14, 20), (13, 20), |
| 1227 | |
| 1228 | (12, 20), (11, 20), (12, 19), (11, 19), (12, 18), (11, 18), |
| 1229 | (12, 17), (11, 17), (12, 16), (11, 16), (12, 15), (11, 15), |
| 1230 | (12, 14), (11, 14), (12, 13), (11, 13), (12, 12), (11, 12), |
| 1231 | (12, 11), (11, 11), (12, 10), (11, 10), (12, 9), (11, 9), |
| 1232 | (12, 8), (11, 8), (12, 7), (11, 7), (12, 6), (11, 6), |
| 1233 | (12, 5), (11, 5), (12, 4), (11, 4), (12, 3), (11, 3), |
| 1234 | (12, 2), (11, 2), (12, 1), (11, 1), (12, 0), (11, 0), |
| 1235 | |
| 1236 | (10, 0), (9, 0), (10, 1), (9, 1), (10, 2), (9, 2), |
| 1237 | (10, 3), (9, 3), (10, 4), (9, 4), (10, 5), (9, 5), |
| 1238 | (10, 6), (9, 6), (10, 7), (9, 7), (10, 8), (9, 8), |
| 1239 | (10, 9), (9, 9), (10, 10), (9, 10), (10, 11), (9, 11), |
| 1240 | (10, 12), (9, 12), (10, 13), (9, 13), (10, 14), (9, 14), |
| 1241 | (10, 15), (9, 15), (10, 16), (9, 16), (10, 17), (9, 17), |
| 1242 | (10, 18), (9, 18), (10, 19), (9, 19), (10, 20), (9, 20), |
| 1243 | |
| 1244 | (8, 20), (7, 20), (8, 19), (7, 19), (8, 18), (7, 18), |
| 1245 | (8, 17), (7, 17), (8, 16), (7, 16), (8, 15), (7, 15), |
| 1246 | (8, 14), (7, 14), (8, 13), (7, 13), (8, 12), (7, 12), |
| 1247 | (8, 11), (7, 11), (8, 10), (7, 10), (8, 9), (7, 9), |
| 1248 | (8, 8), (7, 8), (8, 7), (7, 7), (8, 6), (7, 6), |
| 1249 | (8, 5), (7, 5), (8, 4), (7, 4), (8, 3), (7, 3), |
| 1250 | (8, 2), (7, 2), (8, 1), (7, 1), (8, 0), (7, 0), |
| 1251 | |
| 1252 | (5, 0), (4, 0), (5, 1), (4, 1), (5, 2), (4, 2), |
| 1253 | (5, 3), (4, 3), (5, 4), (4, 4), (5, 5), (4, 5), |
| 1254 | (5, 6), (4, 6), (5, 7), (4, 7), (5, 8), (4, 8), |
| 1255 | (5, 9), (4, 9), (5, 10), (4, 10), (5, 11), (4, 11), |
| 1256 | (5, 12), (4, 12), (5, 13), (4, 13), (5, 14), (4, 14), |
| 1257 | (5, 15), (4, 15), (5, 16), (4, 16), (5, 17), (4, 17), |
| 1258 | (5, 18), (4, 18), (5, 19), (4, 19), (5, 20), (4, 20), |
| 1259 | |
| 1260 | (3, 20), (2, 20), (3, 19), (2, 19), (3, 18), (2, 18), |
| 1261 | (3, 17), (2, 17), (3, 16), (2, 16), (3, 15), (2, 15), |
| 1262 | (3, 14), (2, 14), (3, 13), (2, 13), (3, 12), (2, 12), |
| 1263 | (3, 11), (2, 11), (3, 10), (2, 10), (3, 9), (2, 9), |
| 1264 | (3, 8), (2, 8), (3, 7), (2, 7), (3, 6), (2, 6), |
| 1265 | (3, 5), (2, 5), (3, 4), (2, 4), (3, 3), (2, 3), |
| 1266 | (3, 2), (2, 2), (3, 1), (2, 1), (3, 0), (2, 0), |
| 1267 | |
| 1268 | (1, 0), (0, 0), (1, 1), (0, 1), (1, 2), (0, 2), |
| 1269 | (1, 3), (0, 3), (1, 4), (0, 4), (1, 5), (0, 5), |
| 1270 | (1, 6), (0, 6), (1, 7), (0, 7), (1, 8), (0, 8), |
| 1271 | (1, 9), (0, 9), (1, 10), (0, 10), (1, 11), (0, 11), |
| 1272 | (1, 12), (0, 12), (1, 13), (0, 13), (1, 14), (0, 14), |
| 1273 | (1, 15), (0, 15), (1, 16), (0, 16), (1, 17), (0, 17), |
| 1274 | (1, 18), (0, 18), (1, 19), (0, 19), (1, 20), (0, 20), |
| 1275 | ]); |
| 1276 | } |
| 1277 | |
| 1278 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1279 | fn test_micro_qrrust-analyzer cargo qrcode 0.14.1 canvas/data_iter_tests/test_micro_qr().() { |
| 1280 | let res = DataModuleIterrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[DataModuleIter]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(1)).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(i16, i16)>>(); |
| 1281 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(res, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 1282 | (10, 10), (9, 10), (10, 9), (9, 9), (10, 8), (9, 8), |
| 1283 | (10, 7), (9, 7), (10, 6), (9, 6), (10, 5), (9, 5), |
| 1284 | (10, 4), (9, 4), (10, 3), (9, 3), (10, 2), (9, 2), |
| 1285 | (10, 1), (9, 1), (10, 0), (9, 0), |
| 1286 | |
| 1287 | (8, 0), (7, 0), (8, 1), (7, 1), (8, 2), (7, 2), |
| 1288 | (8, 3), (7, 3), (8, 4), (7, 4), (8, 5), (7, 5), |
| 1289 | (8, 6), (7, 6), (8, 7), (7, 7), (8, 8), (7, 8), |
| 1290 | (8, 9), (7, 9), (8, 10), (7, 10), |
| 1291 | |
| 1292 | (6, 10), (5, 10), (6, 9), (5, 9), (6, 8), (5, 8), |
| 1293 | (6, 7), (5, 7), (6, 6), (5, 6), (6, 5), (5, 5), |
| 1294 | (6, 4), (5, 4), (6, 3), (5, 3), (6, 2), (5, 2), |
| 1295 | (6, 1), (5, 1), (6, 0), (5, 0), |
| 1296 | |
| 1297 | (4, 0), (3, 0), (4, 1), (3, 1), (4, 2), (3, 2), |
| 1298 | (4, 3), (3, 3), (4, 4), (3, 4), (4, 5), (3, 5), |
| 1299 | (4, 6), (3, 6), (4, 7), (3, 7), (4, 8), (3, 8), |
| 1300 | (4, 9), (3, 9), (4, 10), (3, 10), |
| 1301 | |
| 1302 | (2, 10), (1, 10), (2, 9), (1, 9), (2, 8), (1, 8), |
| 1303 | (2, 7), (1, 7), (2, 6), (1, 6), (2, 5), (1, 5), |
| 1304 | (2, 4), (1, 4), (2, 3), (1, 3), (2, 2), (1, 2), |
| 1305 | (2, 1), (1, 1), (2, 0), (1, 0), |
| 1306 | ]); |
| 1307 | } |
| 1308 | |
| 1309 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1310 | fn test_micro_qr_2rust-analyzer cargo qrcode 0.14.1 canvas/data_iter_tests/test_micro_qr_2().() { |
| 1311 | let res = DataModuleIterrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[DataModuleIter]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(2)).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(i16, i16)>>(); |
| 1312 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(res, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 1313 | (12, 12), (11, 12), (12, 11), (11, 11), (12, 10), (11, 10), |
| 1314 | (12, 9), (11, 9), (12, 8), (11, 8), (12, 7), (11, 7), |
| 1315 | (12, 6), (11, 6), (12, 5), (11, 5), (12, 4), (11, 4), |
| 1316 | (12, 3), (11, 3), (12, 2), (11, 2), (12, 1), (11, 1), |
| 1317 | (12, 0), (11, 0), |
| 1318 | |
| 1319 | (10, 0), (9, 0), (10, 1), (9, 1), (10, 2), (9, 2), |
| 1320 | (10, 3), (9, 3), (10, 4), (9, 4), (10, 5), (9, 5), |
| 1321 | (10, 6), (9, 6), (10, 7), (9, 7), (10, 8), (9, 8), |
| 1322 | (10, 9), (9, 9), (10, 10), (9, 10), (10, 11), (9, 11), |
| 1323 | (10, 12), (9, 12), |
| 1324 | |
| 1325 | (8, 12), (7, 12), (8, 11), (7, 11), (8, 10), (7, 10), |
| 1326 | (8, 9), (7, 9), (8, 8), (7, 8), (8, 7), (7, 7), |
| 1327 | (8, 6), (7, 6), (8, 5), (7, 5), (8, 4), (7, 4), |
| 1328 | (8, 3), (7, 3), (8, 2), (7, 2), (8, 1), (7, 1), |
| 1329 | (8, 0), (7, 0), |
| 1330 | |
| 1331 | (6, 0), (5, 0), (6, 1), (5, 1), (6, 2), (5, 2), |
| 1332 | (6, 3), (5, 3), (6, 4), (5, 4), (6, 5), (5, 5), |
| 1333 | (6, 6), (5, 6), (6, 7), (5, 7), (6, 8), (5, 8), |
| 1334 | (6, 9), (5, 9), (6, 10), (5, 10), (6, 11), (5, 11), |
| 1335 | (6, 12), (5, 12), |
| 1336 | |
| 1337 | (4, 12), (3, 12), (4, 11), (3, 11), (4, 10), (3, 10), |
| 1338 | (4, 9), (3, 9), (4, 8), (3, 8), (4, 7), (3, 7), |
| 1339 | (4, 6), (3, 6), (4, 5), (3, 5), (4, 4), (3, 4), |
| 1340 | (4, 3), (3, 3), (4, 2), (3, 2), (4, 1), (3, 1), |
| 1341 | (4, 0), (3, 0), |
| 1342 | |
| 1343 | (2, 0), (1, 0), (2, 1), (1, 1), (2, 2), (1, 2), |
| 1344 | (2, 3), (1, 3), (2, 4), (1, 4), (2, 5), (1, 5), |
| 1345 | (2, 6), (1, 6), (2, 7), (1, 7), (2, 8), (1, 8), |
| 1346 | (2, 9), (1, 9), (2, 10), (1, 10), (2, 11), (1, 11), |
| 1347 | (2, 12), (1, 12), |
| 1348 | ]); |
| 1349 | } |
| 1350 | } |
| 1351 | |
| 1352 | //}}} |
| 1353 | //------------------------------------------------------------------------------ |
| 1354 | //{{{ Data placement |
| 1355 | |
| 1356 | impl Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas# { |
| 1357 | fn draw_codewordsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_codewords().<I>(&mut self, codewords: &[u8], is_half_codeword_at_end: bool, coords: &mut I) |
| 1358 | where |
| 1359 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = (i16, i16)>, |
| 1360 | { |
| 1361 | let length = codewords.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(); |
| 1362 | let last_word = if is_half_codeword_at_end { length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1 } else { length }; |
| 1363 | for (i, b) in codewords.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 1364 | let bits_end = if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().last_word { 4 } else { 0 }; |
| 1365 | 'outside: for j in (bits_end..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#7).revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() { |
| 1366 | let color = if (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().(1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().j)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().0 { Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light# } else { Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark# }; |
| 1367 | for (x, y) in coords.by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().() { |
| 1368 | let r = self.get_mutrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get_mut().(x, y); |
| 1369 | if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().r rust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module][`PartialEq<Self>`]eq().==rust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module][`PartialEq<Self>`]eq(). rust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module][`PartialEq<Self>`]eq().Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Emptyrust-analyzer cargo qrcode 0.14.1 canvas/Module#Empty# { |
| 1370 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().r = Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Unmaskedrust-analyzer cargo qrcode 0.14.1 canvas/Module#Unmasked#(color); |
| 1371 | continue 'outside; |
| 1372 | } |
| 1373 | } |
| 1374 | return; |
| 1375 | } |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | /// Draws the encoded data and error correction codes to the empty modules. |
| 1380 | pub fn draw_datarust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_data().(&mut self, data: &[u8], ec: &[u8]) { |
| 1381 | let is_half_codeword_at_end = |
| 1382 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!((self.versionrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#version., self.ec_levelrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#ec_level.), (Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#) | (Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(3), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Mrust-analyzer cargo qrcode 0.14.1 types/EcLevel#M#)); |
| 1383 | let mut coords = DataModuleIterrust-analyzer cargo qrcode 0.14.1 canvas/DataModuleIter#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[DataModuleIter]new().(self.versionrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#version.); |
| 1384 | self.draw_codewordsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_codewords().(data, is_half_codeword_at_end, &mut coords); |
| 1385 | self.draw_codewordsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_codewords().(ec, false, &mut coords); |
| 1386 | } |
| 1387 | } |
| 1388 | |
| 1389 | #[cfg(test)] |
| 1390 | mod draw_codewords_testrust-analyzer cargo qrcode 0.14.1 canvas/draw_codewords_test/ { |
| 1391 | use craterust-analyzer cargo qrcode 0.14.1 crate/::canvasrust-analyzer cargo qrcode 0.14.1 canvas/::Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#; |
| 1392 | use craterust-analyzer cargo qrcode 0.14.1 crate/::typesrust-analyzer cargo qrcode 0.14.1 types/::{EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#, Versionrust-analyzer cargo qrcode 0.14.1 types/Version#}; |
| 1393 | |
| 1394 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1395 | fn test_micro_qr_1rust-analyzer cargo qrcode 0.14.1 canvas/draw_codewords_test/test_micro_qr_1().() { |
| 1396 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 1397 | c.draw_all_functional_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_all_functional_patterns().(); |
| 1398 | c.draw_datarust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_data().(b"\x6e\x5d\xe2", b"\x2b\x63"); |
| 1399 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1400 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 1401 | "\n\ |
| 1402 | #######.#.#\n\ |
| 1403 | #.....#..-*\n\ |
| 1404 | #.###.#..**\n\ |
| 1405 | #.###.#..*-\n\ |
| 1406 | #.###.#..**\n\ |
| 1407 | #.....#..*-\n\ |
| 1408 | #######..*-\n\ |
| 1409 | .........-*\n\ |
| 1410 | #........**\n\ |
| 1411 | .***-**---*\n\ |
| 1412 | #---*-*-**-" |
| 1413 | ); |
| 1414 | } |
| 1415 | |
| 1416 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1417 | fn test_qr_2rust-analyzer cargo qrcode 0.14.1 canvas/draw_codewords_test/test_qr_2().() { |
| 1418 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(2), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 1419 | c.draw_all_functional_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_all_functional_patterns().(); |
| 1420 | c.draw_datarust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_data().( |
| 1421 | b"\x92I$\x92I$\x92I$\x92I$\x92I$\x92I$\x92I$\x92I$\ |
| 1422 | \x92I$\x92I$\x92I$\x92I$\x92I$\x92I$\x92I$", |
| 1423 | b"", |
| 1424 | ); |
| 1425 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1426 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 1427 | "\n\ |
| 1428 | #######..--*---*-.#######\n\ |
| 1429 | #.....#..-*-*-*-*.#.....#\n\ |
| 1430 | #.###.#..*---*---.#.###.#\n\ |
| 1431 | #.###.#..--*---*-.#.###.#\n\ |
| 1432 | #.###.#..-*-*-*-*.#.###.#\n\ |
| 1433 | #.....#..*---*---.#.....#\n\ |
| 1434 | #######.#.#.#.#.#.#######\n\ |
| 1435 | .........--*---*-........\n\ |
| 1436 | ......#..-*-*-*-*........\n\ |
| 1437 | --*-*-.-**---*---*--**--*\n\ |
| 1438 | -*-*--#----*---*---------\n\ |
| 1439 | *----*.*--*-*-*-*-**--**-\n\ |
| 1440 | --*-*-#-**---*---*--**--*\n\ |
| 1441 | -*-*--.----*---*---------\n\ |
| 1442 | *----*#*--*-*-*-*-**--**-\n\ |
| 1443 | --*-*-.-**---*---*--**--*\n\ |
| 1444 | -*-*--#----*---*#####----\n\ |
| 1445 | ........#-*-*-*-#...#-**-\n\ |
| 1446 | #######..*---*--#.#.#*--*\n\ |
| 1447 | #.....#..--*---*#...#----\n\ |
| 1448 | #.###.#..-*-*-*-#####-**-\n\ |
| 1449 | #.###.#..*---*--*----*--*\n\ |
| 1450 | #.###.#..--*------**-----\n\ |
| 1451 | #.....#..-*-*-**-*--*-**-\n\ |
| 1452 | #######..*---*--*----*--*" |
| 1453 | ); |
| 1454 | } |
| 1455 | } |
| 1456 | //}}} |
| 1457 | //------------------------------------------------------------------------------ |
| 1458 | //{{{ Masking |
| 1459 | |
| 1460 | /// The mask patterns. Since QR code and Micro QR code do not use the same |
| 1461 | /// pattern number, we name them according to their shape instead of the number. |
| 1462 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 1463 | pub enum MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern# { |
| 1464 | /// QR code pattern 000: `(x + y) % 2 == 0`. |
| 1465 | Checkerboardrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Checkerboard# = 0b000, |
| 1466 | |
| 1467 | /// QR code pattern 001: `y % 2 == 0`. |
| 1468 | HorizontalLinesrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#HorizontalLines# = 0b001, |
| 1469 | |
| 1470 | /// QR code pattern 010: `x % 3 == 0`. |
| 1471 | VerticalLinesrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#VerticalLines# = 0b010, |
| 1472 | |
| 1473 | /// QR code pattern 011: `(x + y) % 3 == 0`. |
| 1474 | DiagonalLinesrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#DiagonalLines# = 0b011, |
| 1475 | |
| 1476 | /// QR code pattern 100: `((x/3) + (y/2)) % 2 == 0`. |
| 1477 | LargeCheckerboardrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#LargeCheckerboard# = 0b100, |
| 1478 | |
| 1479 | /// QR code pattern 101: `(x*y)%2 + (x*y)%3 == 0`. |
| 1480 | Fieldsrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Fields# = 0b101, |
| 1481 | |
| 1482 | /// QR code pattern 110: `((x*y)%2 + (x*y)%3) % 2 == 0`. |
| 1483 | Diamondsrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Diamonds# = 0b110, |
| 1484 | |
| 1485 | /// QR code pattern 111: `((x+y)%2 + (x*y)%3) % 2 == 0`. |
| 1486 | Meadowrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Meadow# = 0b111, |
| 1487 | } |
| 1488 | |
| 1489 | mod mask_functionsrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/ { |
| 1490 | pub fn checkerboardrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/checkerboard().(x: i16, y: i16) -> bool { |
| 1491 | (x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().y) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 |
| 1492 | } |
| 1493 | pub fn horizontal_linesrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/horizontal_lines().(_: i16, y: i16) -> bool { |
| 1494 | y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 |
| 1495 | } |
| 1496 | pub fn vertical_linesrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/vertical_lines().(x: i16, _: i16) -> bool { |
| 1497 | x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 |
| 1498 | } |
| 1499 | pub fn diagonal_linesrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/diagonal_lines().(x: i16, y: i16) -> bool { |
| 1500 | (x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().y) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 |
| 1501 | } |
| 1502 | pub fn large_checkerboardrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/large_checkerboard().(x: i16, y: i16) -> bool { |
| 1503 | ((y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div().2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().(x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Div<Self>`]div().3)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 |
| 1504 | } |
| 1505 | pub fn fieldsrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/fields().(x: i16, y: i16) -> bool { |
| 1506 | (x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().y) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().(x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().y) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 |
| 1507 | } |
| 1508 | pub fn diamondsrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/diamonds().(x: i16, y: i16) -> bool { |
| 1509 | ((x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().y) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().(x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().y) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().3) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 |
| 1510 | } |
| 1511 | pub fn meadowrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/meadow().(x: i16, y: i16) -> bool { |
| 1512 | ((x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().y) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().(x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().y) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().3) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 |
| 1513 | } |
| 1514 | } |
| 1515 | |
| 1516 | fn get_mask_functionrust-analyzer cargo qrcode 0.14.1 canvas/get_mask_function().(pattern: MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#) -> fn(i16, i16) -> bool { |
| 1517 | match pattern { |
| 1518 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::Checkerboardrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Checkerboard# => mask_functionsrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/::checkerboardrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/checkerboard()., |
| 1519 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::HorizontalLinesrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#HorizontalLines# => mask_functionsrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/::horizontal_linesrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/horizontal_lines()., |
| 1520 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::VerticalLinesrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#VerticalLines# => mask_functionsrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/::vertical_linesrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/vertical_lines()., |
| 1521 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::DiagonalLinesrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#DiagonalLines# => mask_functionsrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/::diagonal_linesrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/diagonal_lines()., |
| 1522 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::LargeCheckerboardrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#LargeCheckerboard# => mask_functionsrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/::large_checkerboardrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/large_checkerboard()., |
| 1523 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::Fieldsrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Fields# => mask_functionsrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/::fieldsrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/fields()., |
| 1524 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::Diamondsrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Diamonds# => mask_functionsrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/::diamondsrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/diamonds()., |
| 1525 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::Meadowrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Meadow# => mask_functionsrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/::meadowrust-analyzer cargo qrcode 0.14.1 canvas/mask_functions/meadow()., |
| 1526 | } |
| 1527 | } |
| 1528 | |
| 1529 | impl Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas# { |
| 1530 | /// Applies a mask to the canvas. This method will also draw the format info |
| 1531 | /// patterns. |
| 1532 | pub fn apply_maskrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]apply_mask().(&mut self, pattern: MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#) { |
| 1533 | let mask_fn = get_mask_functionrust-analyzer cargo qrcode 0.14.1 canvas/get_mask_function().(pattern); |
| 1534 | for x in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width. { |
| 1535 | for y in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width. { |
| 1536 | let module = self.get_mutrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get_mut().(x, y); |
| 1537 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().module = module.maskrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module]mask().(mask_fn(x, y)); |
| 1538 | } |
| 1539 | } |
| 1540 | |
| 1541 | self.draw_format_info_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_format_info_patterns().(pattern); |
| 1542 | } |
| 1543 | |
| 1544 | /// Draws the format information to encode the error correction level and |
| 1545 | /// mask pattern. |
| 1546 | /// |
| 1547 | /// If the error correction level or mask pattern is not supported in the |
| 1548 | /// current QR code version, this method will fail. |
| 1549 | fn draw_format_info_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_format_info_patterns().(&mut self, pattern: MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#) { |
| 1550 | let format_number = match self.versionrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#version. { |
| 1551 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(_) => { |
| 1552 | let simple_format_number = ((self.ec_levelrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#ec_level. as usize) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitXor<Self>`]bitxor().^rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitXor<Self>`]bitxor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitXor<Self>`]bitxor().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl().3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitOr<Self>`]bitor().(pattern as usize); |
| 1553 | FORMAT_INFOS_QRrust-analyzer cargo qrcode 0.14.1 canvas/FORMAT_INFOS_QR.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().simple_format_number]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). |
| 1554 | } |
| 1555 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(a) => { |
| 1556 | let micro_pattern_number = match pattern { |
| 1557 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::HorizontalLinesrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#HorizontalLines# => 0b00, |
| 1558 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::LargeCheckerboardrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#LargeCheckerboard# => 0b01, |
| 1559 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::Diamondsrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Diamonds# => 0b10, |
| 1560 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::Meadowrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Meadow# => 0b11, |
| 1561 | _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Unsupported mask pattern in Micro QR code"), |
| 1562 | }; |
| 1563 | let symbol_number = match (a, self.ec_levelrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#ec_level.) { |
| 1564 | (1, EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#) => 0b000, |
| 1565 | (2, EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#) => 0b001, |
| 1566 | (2, EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Mrust-analyzer cargo qrcode 0.14.1 types/EcLevel#M#) => 0b010, |
| 1567 | (3, EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#) => 0b011, |
| 1568 | (3, EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Mrust-analyzer cargo qrcode 0.14.1 types/EcLevel#M#) => 0b100, |
| 1569 | (4, EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#) => 0b101, |
| 1570 | (4, EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Mrust-analyzer cargo qrcode 0.14.1 types/EcLevel#M#) => 0b110, |
| 1571 | (4, EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Qrust-analyzer cargo qrcode 0.14.1 types/EcLevel#Q#) => 0b111, |
| 1572 | _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Unsupported version/ec_level combination in Micro QR code"), |
| 1573 | }; |
| 1574 | let simple_format_number = symbol_number rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitOr<Self>`]bitor().micro_pattern_number; |
| 1575 | FORMAT_INFOS_MICRO_QRrust-analyzer cargo qrcode 0.14.1 canvas/FORMAT_INFOS_MICRO_QR.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().simple_format_number]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). |
| 1576 | } |
| 1577 | }; |
| 1578 | self.draw_format_info_patterns_with_numberrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_format_info_patterns_with_number().(format_number); |
| 1579 | } |
| 1580 | } |
| 1581 | |
| 1582 | #[cfg(test)] |
| 1583 | mod mask_testsrust-analyzer cargo qrcode 0.14.1 canvas/mask_tests/ { |
| 1584 | use craterust-analyzer cargo qrcode 0.14.1 crate/::canvasrust-analyzer cargo qrcode 0.14.1 canvas/::{Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#, MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#}; |
| 1585 | use craterust-analyzer cargo qrcode 0.14.1 crate/::typesrust-analyzer cargo qrcode 0.14.1 types/::{EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#, Versionrust-analyzer cargo qrcode 0.14.1 types/Version#}; |
| 1586 | |
| 1587 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1588 | fn test_apply_mask_qrrust-analyzer cargo qrcode 0.14.1 canvas/mask_tests/test_apply_mask_qr().() { |
| 1589 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 1590 | c.draw_all_functional_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_all_functional_patterns().(); |
| 1591 | c.apply_maskrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]apply_mask().(MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::Checkerboardrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Checkerboard#); |
| 1592 | |
| 1593 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1594 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 1595 | "\n\ |
| 1596 | #######...#.#.#######\n\ |
| 1597 | #.....#..#.#..#.....#\n\ |
| 1598 | #.###.#.#.#.#.#.###.#\n\ |
| 1599 | #.###.#..#.#..#.###.#\n\ |
| 1600 | #.###.#...#.#.#.###.#\n\ |
| 1601 | #.....#..#.#..#.....#\n\ |
| 1602 | #######.#.#.#.#######\n\ |
| 1603 | ........##.#.........\n\ |
| 1604 | ###.#####.#.###...#..\n\ |
| 1605 | .#.#.#.#.#.#.#.#.#.#.\n\ |
| 1606 | #.#.#.#.#.#.#.#.#.#.#\n\ |
| 1607 | .#.#.#.#.#.#.#.#.#.#.\n\ |
| 1608 | #.#.#.#.#.#.#.#.#.#.#\n\ |
| 1609 | ........##.#.#.#.#.#.\n\ |
| 1610 | #######.#.#.#.#.#.#.#\n\ |
| 1611 | #.....#.##.#.#.#.#.#.\n\ |
| 1612 | #.###.#.#.#.#.#.#.#.#\n\ |
| 1613 | #.###.#..#.#.#.#.#.#.\n\ |
| 1614 | #.###.#.#.#.#.#.#.#.#\n\ |
| 1615 | #.....#.##.#.#.#.#.#.\n\ |
| 1616 | #######.#.#.#.#.#.#.#" |
| 1617 | ); |
| 1618 | } |
| 1619 | |
| 1620 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1621 | fn test_draw_format_info_patterns_qrrust-analyzer cargo qrcode 0.14.1 canvas/mask_tests/test_draw_format_info_patterns_qr().() { |
| 1622 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 1623 | c.draw_format_info_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_format_info_patterns().(MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::LargeCheckerboardrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#LargeCheckerboard#); |
| 1624 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1625 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 1626 | "\n\ |
| 1627 | ????????#????????????\n\ |
| 1628 | ????????#????????????\n\ |
| 1629 | ????????#????????????\n\ |
| 1630 | ????????#????????????\n\ |
| 1631 | ????????.????????????\n\ |
| 1632 | ????????#????????????\n\ |
| 1633 | ?????????????????????\n\ |
| 1634 | ????????.????????????\n\ |
| 1635 | ##..##?..????..#.####\n\ |
| 1636 | ?????????????????????\n\ |
| 1637 | ?????????????????????\n\ |
| 1638 | ?????????????????????\n\ |
| 1639 | ?????????????????????\n\ |
| 1640 | ????????#????????????\n\ |
| 1641 | ????????.????????????\n\ |
| 1642 | ????????#????????????\n\ |
| 1643 | ????????#????????????\n\ |
| 1644 | ????????.????????????\n\ |
| 1645 | ????????.????????????\n\ |
| 1646 | ????????#????????????\n\ |
| 1647 | ????????#????????????" |
| 1648 | ); |
| 1649 | } |
| 1650 | |
| 1651 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1652 | fn test_draw_format_info_patterns_micro_qrrust-analyzer cargo qrcode 0.14.1 canvas/mask_tests/test_draw_format_info_patterns_micro_qr().() { |
| 1653 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(2), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Lrust-analyzer cargo qrcode 0.14.1 types/EcLevel#L#); |
| 1654 | c.draw_format_info_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_format_info_patterns().(MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::LargeCheckerboardrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#LargeCheckerboard#); |
| 1655 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1656 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 1657 | "\n\ |
| 1658 | ?????????????\n\ |
| 1659 | ????????#????\n\ |
| 1660 | ????????.????\n\ |
| 1661 | ????????.????\n\ |
| 1662 | ????????#????\n\ |
| 1663 | ????????#????\n\ |
| 1664 | ????????.????\n\ |
| 1665 | ????????.????\n\ |
| 1666 | ?#.#....#????\n\ |
| 1667 | ?????????????\n\ |
| 1668 | ?????????????\n\ |
| 1669 | ?????????????\n\ |
| 1670 | ?????????????" |
| 1671 | ); |
| 1672 | } |
| 1673 | } |
| 1674 | |
| 1675 | static FORMAT_INFOS_QRrust-analyzer cargo qrcode 0.14.1 canvas/FORMAT_INFOS_QR.: [u16; 32] = [ |
| 1676 | 0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, 0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, |
| 1677 | 0x6c41, 0x6976, 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b, 0x355f, 0x3068, 0x3f31, 0x3a06, |
| 1678 | 0x24b4, 0x2183, 0x2eda, 0x2bed, |
| 1679 | ]; |
| 1680 | |
| 1681 | static FORMAT_INFOS_MICRO_QRrust-analyzer cargo qrcode 0.14.1 canvas/FORMAT_INFOS_MICRO_QR.: [u16; 32] = [ |
| 1682 | 0x4445, 0x4172, 0x4e2b, 0x4b1c, 0x55ae, 0x5099, 0x5fc0, 0x5af7, 0x6793, 0x62a4, 0x6dfd, 0x68ca, 0x7678, 0x734f, |
| 1683 | 0x7c16, 0x7921, 0x06de, 0x03e9, 0x0cb0, 0x0987, 0x1735, 0x1202, 0x1d5b, 0x186c, 0x2508, 0x203f, 0x2f66, 0x2a51, |
| 1684 | 0x34e3, 0x31d4, 0x3e8d, 0x3bba, |
| 1685 | ]; |
| 1686 | |
| 1687 | //}}} |
| 1688 | //------------------------------------------------------------------------------ |
| 1689 | //{{{ Penalty score |
| 1690 | |
| 1691 | impl Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas# { |
| 1692 | /// Compute the penalty score for having too many adjacent modules with the |
| 1693 | /// same color. |
| 1694 | /// |
| 1695 | /// Every 5+N adjacent modules in the same column/row having the same color |
| 1696 | /// will contribute 3+N points. |
| 1697 | fn compute_adjacent_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_adjacent_penalty_score().(&self, is_horizontal: bool) -> u16 { |
| 1698 | let mut total_score = 0; |
| 1699 | |
| 1700 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width. { |
| 1701 | let map_fn = |j| if is_horizontal { self.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(j, i) } else { self.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(i, j) }; |
| 1702 | |
| 1703 | let colors = (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width.).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(map_fn).chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#chain().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Emptyrust-analyzer cargo qrcode 0.14.1 canvas/Module#Empty#).into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][IntoIterator]into_iter().()); |
| 1704 | let mut last_color = Modulerust-analyzer cargo qrcode 0.14.1 canvas/Module#::Emptyrust-analyzer cargo qrcode 0.14.1 canvas/Module#Empty#; |
| 1705 | let mut consecutive_len = 1_u16; |
| 1706 | |
| 1707 | for color in colors { |
| 1708 | if color rust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module][`PartialEq<Self>`]eq().==rust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module][`PartialEq<Self>`]eq(). rust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module][`PartialEq<Self>`]eq().last_color { |
| 1709 | consecutive_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign().1; |
| 1710 | } else { |
| 1711 | last_color = color; |
| 1712 | if consecutive_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]ge().5 { |
| 1713 | total_score rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign().consecutive_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().2; |
| 1714 | } |
| 1715 | consecutive_len = 1; |
| 1716 | } |
| 1717 | } |
| 1718 | } |
| 1719 | |
| 1720 | total_score |
| 1721 | } |
| 1722 | |
| 1723 | /// Compute the penalty score for having too many rectangles with the same |
| 1724 | /// color. |
| 1725 | /// |
| 1726 | /// Every 2×2 blocks (with overlapping counted) having the same color will |
| 1727 | /// contribute 3 points. |
| 1728 | fn compute_block_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_block_penalty_score().(&self) -> u16 { |
| 1729 | let mut total_score = 0; |
| 1730 | |
| 1731 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().1 { |
| 1732 | for j in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().1 { |
| 1733 | let this = self.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(i, j); |
| 1734 | let right = self.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1, j); |
| 1735 | let bottom = self.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(i, j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1); |
| 1736 | let bottom_right = self.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1, j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1); |
| 1737 | if this rust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module][`PartialEq<Self>`]eq().==rust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module][`PartialEq<Self>`]eq(). rust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module][`PartialEq<Self>`]eq().right && right rust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module][`PartialEq<Self>`]eq().==rust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module][`PartialEq<Self>`]eq(). rust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module][`PartialEq<Self>`]eq().bottom && bottom rust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module][`PartialEq<Self>`]eq().==rust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module][`PartialEq<Self>`]eq(). rust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module][`PartialEq<Self>`]eq().bottom_right { |
| 1738 | total_score rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign().3; |
| 1739 | } |
| 1740 | } |
| 1741 | } |
| 1742 | |
| 1743 | total_score |
| 1744 | } |
| 1745 | |
| 1746 | /// Compute the penalty score for having a pattern similar to the finder |
| 1747 | /// pattern in the wrong place. |
| 1748 | /// |
| 1749 | /// Every pattern that looks like `#.###.#....` in any orientation will add |
| 1750 | /// 40 points. |
| 1751 | fn compute_finder_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_finder_penalty_score().(&self, is_horizontal: bool) -> u16 { |
| 1752 | static PATTERNrust-analyzer cargo qrcode 0.14.1 canvas/PATTERN.: [Colorrust-analyzer cargo qrcode 0.14.1 types/Color#; 7] = |
| 1753 | [Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#]; |
| 1754 | |
| 1755 | let mut total_score = 0; |
| 1756 | |
| 1757 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width. { |
| 1758 | for j in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().6 { |
| 1759 | // TODO a ref to a closure should be enough? |
| 1760 | let get: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(i16) -> Colorrust-analyzer cargo qrcode 0.14.1 types/Color#> = if is_horizontal { |
| 1761 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(|k| self.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(k, i).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 1762 | } else { |
| 1763 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(|k| self.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(i, k).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 1764 | }; |
| 1765 | |
| 1766 | if (j..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().7)).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][Deref]deref().get).nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#ne().(PATTERNrust-analyzer cargo qrcode 0.14.1 canvas/PATTERN..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#copied().()) { |
| 1767 | continue; |
| 1768 | } |
| 1769 | |
| 1770 | let check = |k| 0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().k && k rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width. && get(k) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#; |
| 1771 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().((j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().4)..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#j).anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#any().(&check) || !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().((j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().7)..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().11)).anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#any().(&check) { |
| 1772 | total_score rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign().40; |
| 1773 | } |
| 1774 | } |
| 1775 | } |
| 1776 | |
| 1777 | total_score rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().360 |
| 1778 | } |
| 1779 | |
| 1780 | /// Compute the penalty score for having an unbalanced dark/light ratio. |
| 1781 | /// |
| 1782 | /// The score is given linearly by the deviation from a 50% ratio of dark |
| 1783 | /// modules. The highest possible score is 100. |
| 1784 | /// |
| 1785 | /// Note that this algorithm differs slightly from the standard we do not |
| 1786 | /// round the result every 5%, but the difference should be negligible and |
| 1787 | /// should not affect which mask is chosen. |
| 1788 | fn compute_balance_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_balance_penalty_score().(&self) -> u16 { |
| 1789 | let dark_modules = self.modulesrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#modules..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|m| m.is_darkrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module]is_dark().()).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter/impl#[`Filter<I, P>`][Iterator]count().(); |
| 1790 | let total_modules = self.modulesrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#modules..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(); |
| 1791 | let ratio = dark_modules rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().200 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().total_modules; |
| 1792 | if ratio rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().100 { ratio rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().100 } else { 100 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().ratio }.as_u16rust-analyzer cargo qrcode 0.14.1 cast/impl#[usize][As]as_u16().() |
| 1793 | } |
| 1794 | |
| 1795 | /// Compute the penalty score for having too many light modules on the sides. |
| 1796 | /// |
| 1797 | /// This penalty score is exclusive to Micro QR code. |
| 1798 | /// |
| 1799 | /// Note that the standard gives the formula for *efficiency* score, which |
| 1800 | /// has the inverse meaning of this method, but it is very easy to convert |
| 1801 | /// between the two (this score is (16×width − standard-score)). |
| 1802 | fn compute_light_side_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_light_side_penalty_score().(&self) -> u16 { |
| 1803 | let h = (1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width.).filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|j| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().j, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().1).is_darkrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module]is_dark().()).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter/impl#[`Filter<I, P>`][Iterator]count().(); |
| 1804 | let v = (1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.widthrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#width.).filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|j| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.getrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]get().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().1, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().j).is_darkrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module]is_dark().()).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter/impl#[`Filter<I, P>`][Iterator]count().(); |
| 1805 | |
| 1806 | (h rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().v rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().15 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(h, v)).as_u16rust-analyzer cargo qrcode 0.14.1 cast/impl#[usize][As]as_u16().() |
| 1807 | } |
| 1808 | |
| 1809 | /// Compute the total penalty scores. A QR code having higher points is less |
| 1810 | /// desirable. |
| 1811 | fn compute_total_penalty_scoresrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_total_penalty_scores().(&self) -> u16 { |
| 1812 | match self.versionrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#version. { |
| 1813 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(_) => { |
| 1814 | let s1_a = self.compute_adjacent_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_adjacent_penalty_score().(true); |
| 1815 | let s1_b = self.compute_adjacent_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_adjacent_penalty_score().(false); |
| 1816 | let s2 = self.compute_block_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_block_penalty_score().(); |
| 1817 | let s3_a = self.compute_finder_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_finder_penalty_score().(true); |
| 1818 | let s3_b = self.compute_finder_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_finder_penalty_score().(false); |
| 1819 | let s4 = self.compute_balance_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_balance_penalty_score().(); |
| 1820 | s1_a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().s1_b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().s2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().s3_a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().s3_b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().s4 |
| 1821 | } |
| 1822 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(_) => self.compute_light_side_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_light_side_penalty_score().(), |
| 1823 | } |
| 1824 | } |
| 1825 | } |
| 1826 | |
| 1827 | #[cfg(test)] |
| 1828 | mod penalty_testsrust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/ { |
| 1829 | use craterust-analyzer cargo qrcode 0.14.1 crate/::canvasrust-analyzer cargo qrcode 0.14.1 canvas/::{Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#, MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#}; |
| 1830 | use craterust-analyzer cargo qrcode 0.14.1 crate/::typesrust-analyzer cargo qrcode 0.14.1 types/::{Colorrust-analyzer cargo qrcode 0.14.1 types/Color#, EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#, Versionrust-analyzer cargo qrcode 0.14.1 types/Version#}; |
| 1831 | |
| 1832 | fn create_test_canvasrust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/create_test_canvas().() -> Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas# { |
| 1833 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Qrust-analyzer cargo qrcode 0.14.1 types/EcLevel#Q#); |
| 1834 | c.draw_all_functional_patternsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_all_functional_patterns().(); |
| 1835 | c.draw_datarust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]draw_data().( |
| 1836 | b"\x20\x5b\x0b\x78\xd1\x72\xdc\x4d\x43\x40\xec\x11\x00", |
| 1837 | b"\xa8\x48\x16\x52\xd9\x36\x9c\x00\x2e\x0f\xb4\x7a\x10", |
| 1838 | ); |
| 1839 | c.apply_maskrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]apply_mask().(MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::Checkerboardrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Checkerboard#); |
| 1840 | c |
| 1841 | } |
| 1842 | |
| 1843 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1844 | fn check_penalty_canvasrust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/check_penalty_canvas().() { |
| 1845 | let c = create_test_canvasrust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/create_test_canvas().(); |
| 1846 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1847 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().c.to_debug_strrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_debug_str().(), |
| 1848 | "\n\ |
| 1849 | #######.##....#######\n\ |
| 1850 | #.....#.#..#..#.....#\n\ |
| 1851 | #.###.#.#..##.#.###.#\n\ |
| 1852 | #.###.#.#.....#.###.#\n\ |
| 1853 | #.###.#.#.#...#.###.#\n\ |
| 1854 | #.....#...#...#.....#\n\ |
| 1855 | #######.#.#.#.#######\n\ |
| 1856 | ........#............\n\ |
| 1857 | .##.#.##....#.#.#####\n\ |
| 1858 | .#......####....#...#\n\ |
| 1859 | ..##.###.##...#.##...\n\ |
| 1860 | .##.##.#..##.#.#.###.\n\ |
| 1861 | #...#.#.#.###.###.#.#\n\ |
| 1862 | ........##.#..#...#.#\n\ |
| 1863 | #######.#.#....#.##..\n\ |
| 1864 | #.....#..#.##.##.#...\n\ |
| 1865 | #.###.#.#.#...#######\n\ |
| 1866 | #.###.#..#.#.#.#...#.\n\ |
| 1867 | #.###.#.#...####.#..#\n\ |
| 1868 | #.....#.#.##.#...#.##\n\ |
| 1869 | #######.....####....#" |
| 1870 | ); |
| 1871 | } |
| 1872 | |
| 1873 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1874 | fn test_penalty_score_adjacentrust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/test_penalty_score_adjacent().() { |
| 1875 | let c = create_test_canvasrust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/create_test_canvas().(); |
| 1876 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.compute_adjacent_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_adjacent_penalty_score().(true), 88); |
| 1877 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.compute_adjacent_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_adjacent_penalty_score().(false), 92); |
| 1878 | } |
| 1879 | |
| 1880 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1881 | fn test_penalty_score_blockrust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/test_penalty_score_block().() { |
| 1882 | let c = create_test_canvasrust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/create_test_canvas().(); |
| 1883 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.compute_block_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_block_penalty_score().(), 90); |
| 1884 | } |
| 1885 | |
| 1886 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1887 | fn test_penalty_score_finderrust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/test_penalty_score_finder().() { |
| 1888 | let c = create_test_canvasrust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/create_test_canvas().(); |
| 1889 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.compute_finder_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_finder_penalty_score().(true), 0); |
| 1890 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.compute_finder_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_finder_penalty_score().(false), 40); |
| 1891 | } |
| 1892 | |
| 1893 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1894 | fn test_penalty_score_balancerust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/test_penalty_score_balance().() { |
| 1895 | let c = create_test_canvasrust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/create_test_canvas().(); |
| 1896 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.compute_balance_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_balance_penalty_score().(), 2); |
| 1897 | } |
| 1898 | |
| 1899 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1900 | fn test_penalty_score_light_sidesrust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/test_penalty_score_light_sides().() { |
| 1901 | static HORIZONTAL_SIDErust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/HORIZONTAL_SIDE.: [Colorrust-analyzer cargo qrcode 0.14.1 types/Color#; 17] = [ |
| 1902 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1903 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1904 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1905 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1906 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1907 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1908 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1909 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1910 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1911 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1912 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1913 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1914 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1915 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1916 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1917 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1918 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1919 | ]; |
| 1920 | static VERTICAL_SIDErust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/VERTICAL_SIDE.: [Colorrust-analyzer cargo qrcode 0.14.1 types/Color#; 17] = [ |
| 1921 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1922 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1923 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1924 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1925 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1926 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1927 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1928 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1929 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1930 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1931 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1932 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1933 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1934 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1935 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1936 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Darkrust-analyzer cargo qrcode 0.14.1 types/Color#Dark#, |
| 1937 | Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::Lightrust-analyzer cargo qrcode 0.14.1 types/Color#Light#, |
| 1938 | ]; |
| 1939 | |
| 1940 | let mut c = Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#::newrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]new().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(4), EcLevelrust-analyzer cargo qrcode 0.14.1 types/EcLevel#::Qrust-analyzer cargo qrcode 0.14.1 types/EcLevel#Q#); |
| 1941 | for i in 0_i16..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#17 { |
| 1942 | c.putrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]put().(i, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().1, HORIZONTAL_SIDErust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/HORIZONTAL_SIDE.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().i as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 1943 | c.putrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]put().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().1, i, VERTICAL_SIDErust-analyzer cargo qrcode 0.14.1 canvas/penalty_tests/VERTICAL_SIDE.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().i as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 1944 | } |
| 1945 | |
| 1946 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.compute_light_side_penalty_scorerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_light_side_penalty_score().(), 168); |
| 1947 | } |
| 1948 | } |
| 1949 | |
| 1950 | //}}} |
| 1951 | //------------------------------------------------------------------------------ |
| 1952 | //{{{ Select mask with lowest penalty score |
| 1953 | |
| 1954 | static ALL_PATTERNS_QRrust-analyzer cargo qrcode 0.14.1 canvas/ALL_PATTERNS_QR.: [MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#; 8] = [ |
| 1955 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::Checkerboardrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Checkerboard#, |
| 1956 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::HorizontalLinesrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#HorizontalLines#, |
| 1957 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::VerticalLinesrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#VerticalLines#, |
| 1958 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::DiagonalLinesrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#DiagonalLines#, |
| 1959 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::LargeCheckerboardrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#LargeCheckerboard#, |
| 1960 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::Fieldsrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Fields#, |
| 1961 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::Diamondsrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Diamonds#, |
| 1962 | MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::Meadowrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Meadow#, |
| 1963 | ]; |
| 1964 | |
| 1965 | static ALL_PATTERNS_MICRO_QRrust-analyzer cargo qrcode 0.14.1 canvas/ALL_PATTERNS_MICRO_QR.: [MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#; 4] = |
| 1966 | [MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::HorizontalLinesrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#HorizontalLines#, MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::LargeCheckerboardrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#LargeCheckerboard#, MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::Diamondsrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Diamonds#, MaskPatternrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#::Meadowrust-analyzer cargo qrcode 0.14.1 canvas/MaskPattern#Meadow#]; |
| 1967 | |
| 1968 | impl Canvasrust-analyzer cargo qrcode 0.14.1 canvas/Canvas# { |
| 1969 | /// Construct a new canvas and apply the best masking that gives the lowest |
| 1970 | /// penalty score. |
| 1971 | #[allow(clippy::missing_panics_doc)] // the expect() only panics when the input iterators (ALL_PATTERNS_QR, ALL_PATTERNS_MICRO_QR) are empty |
| 1972 | #[must_use] |
| 1973 | pub fn apply_best_maskrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]apply_best_mask().(&self) -> Selfrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas] { |
| 1974 | match self.versionrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#version. { |
| 1975 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(_) => ALL_PATTERNS_QRrust-analyzer cargo qrcode 0.14.1 canvas/ALL_PATTERNS_QR..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().(), |
| 1976 | Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(_) => ALL_PATTERNS_MICRO_QRrust-analyzer cargo qrcode 0.14.1 canvas/ALL_PATTERNS_MICRO_QR..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().(), |
| 1977 | } |
| 1978 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|ptn| { |
| 1979 | let mut c = self.clonerust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas][Clone]clone().(); |
| 1980 | c.apply_maskrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]apply_mask().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ptn); |
| 1981 | c |
| 1982 | }) |
| 1983 | .min_by_keyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#min_by_key().(Selfrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]::compute_total_penalty_scoresrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]compute_total_penalty_scores().) |
| 1984 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("at least one pattern") |
| 1985 | } |
| 1986 | |
| 1987 | /// Convert the modules into a vector of booleans. |
| 1988 | #[deprecated(since = "0.4.0", note = "use `into_colors()` instead")] |
| 1989 | pub fn to_boolsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]to_bools().(&self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<bool> { |
| 1990 | self.modulesrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#modules..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|m| m.is_darkrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Module]is_dark().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 1991 | } |
| 1992 | |
| 1993 | /// Convert the modules into a vector of colors. |
| 1994 | pub fn into_colorsrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Canvas]into_colors().(self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Colorrust-analyzer cargo qrcode 0.14.1 types/Color#> { |
| 1995 | self.modulesrust-analyzer cargo qrcode 0.14.1 canvas/Canvas#modules..into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(Colorrust-analyzer cargo qrcode 0.14.1 types/Color#::fromrust-analyzer cargo qrcode 0.14.1 canvas/impl#[Color][`From<Module>`]from().).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 1996 | } |
| 1997 | } |
| 1998 | |
| 1999 | //}}} |
| 2000 | //------------------------------------------------------------------------------ |