@@ -34,7 +34,10 @@ pub trait Pixel: Copy + Sized {
3434
3535/// Rendering canvas of a QR code image.
3636pub trait Canvas : Sized {
37+ /// Type of an image pixel.
3738 type Pixel : Sized ;
39+
40+ /// Type of the finalized image.
3841 type Image : Sized ;
3942
4043 /// Constructs a new canvas of the given dimensions.
@@ -43,6 +46,8 @@ pub trait Canvas: Sized {
4346 /// Draws a single dark pixel at the (x, y) coordinate.
4447 fn draw_dark_pixel ( & mut self , x : u32 , y : u32 ) ;
4548
49+ /// Draws a dark rectangle with dimensions `width`×`height` at the (`left`,
50+ /// `top`) coordinate.
4651 fn draw_dark_rect ( & mut self , left : u32 , top : u32 , width : u32 , height : u32 ) {
4752 for y in top..( top + height) {
4853 for x in left..( left + width) {
@@ -121,6 +126,14 @@ impl<'a, P: Pixel> Renderer<'a, P> {
121126 self
122127 }
123128
129+ /// Sets the minimum total image width (and thus height) in pixels,
130+ /// including the quiet zone if applicable. The renderer will try to find
131+ /// the dimension as small as possible, such that each module in the QR code
132+ /// has uniform size (no distortion).
133+ ///
134+ /// For instance, a version 1 QR code has 19 modules across including the
135+ /// quiet zone. If we request an image of width ≥200px, we get that each
136+ /// module's size should be 11px, so the actual image size will be 209px.
124137 #[ deprecated( since = "0.4.0" , note = "use `.min_dimensions(width, width)` instead" ) ]
125138 pub fn min_width ( & mut self , width : u32 ) -> & mut Self {
126139 self . min_dimensions ( width, width)
0 commit comments