pub struct Renderer<'a, P: Pixel> { /* private fields */ }
Expand description
A QR code renderer. This is a builder type which converts a bool-vector into an image.
Implementations§
source§impl<'a, P: Pixel> Renderer<'a, P>
impl<'a, P: Pixel> Renderer<'a, P>
sourcepub fn new(
content: &'a [Color],
modules_count: usize,
quiet_zone: u32
) -> Renderer<'a, P>
pub fn new( content: &'a [Color], modules_count: usize, quiet_zone: u32 ) -> Renderer<'a, P>
Creates a new renderer.
§Panics
Panics if the length of content
is not exactly modules_count * modules_count
.
sourcepub fn dark_color(&mut self, color: P) -> &mut Self
pub fn dark_color(&mut self, color: P) -> &mut Self
Sets color of a dark module. Default is opaque black.
sourcepub fn light_color(&mut self, color: P) -> &mut Self
pub fn light_color(&mut self, color: P) -> &mut Self
Sets color of a light module. Default is opaque white.
sourcepub fn quiet_zone(&mut self, has_quiet_zone: bool) -> &mut Self
pub fn quiet_zone(&mut self, has_quiet_zone: bool) -> &mut Self
Whether to include the quiet zone in the generated image.
sourcepub fn module_size(&mut self, width: u32) -> &mut Self
👎Deprecated since 0.4.0: use .module_dimensions(width, width)
instead
pub fn module_size(&mut self, width: u32) -> &mut Self
.module_dimensions(width, width)
insteadSets the size of each module in pixels. Default is 8px.
sourcepub fn module_dimensions(&mut self, width: u32, height: u32) -> &mut Self
pub fn module_dimensions(&mut self, width: u32, height: u32) -> &mut Self
Sets the size of each module in pixels. Default is 8×8.
pub fn min_width(&mut self, width: u32) -> &mut Self
.min_dimensions(width, width)
insteadsourcepub fn min_dimensions(&mut self, width: u32, height: u32) -> &mut Self
pub fn min_dimensions(&mut self, width: u32, height: u32) -> &mut Self
Sets the minimum total image size in pixels, including the quiet zone if applicable. The renderer will try to find the dimension as small as possible, such that each module in the QR code has uniform size (no distortion).
For instance, a version 1 QR code has 19 modules across including the quiet zone. If we request an image of size ≥200×200, we get that each module’s size should be 11×11, so the actual image size will be 209×209.
sourcepub fn max_dimensions(&mut self, width: u32, height: u32) -> &mut Self
pub fn max_dimensions(&mut self, width: u32, height: u32) -> &mut Self
Sets the maximum total image size in pixels, including the quiet zone if applicable. The renderer will try to find the dimension as large as possible, such that each module in the QR code has uniform size (no distortion).
For instance, a version 1 QR code has 19 modules across including the quiet zone. If we request an image of size ≤200×200, we get that each module’s size should be 10×10, so the actual image size will be 190×190.
The module size is at least 1×1, so if the restriction is too small, the final image can be larger than the input.