New Wiki page
commit
e6084b182a
|
@ -0,0 +1,36 @@
|
|||
The library doesn't take care of the quiet zones which are required by some barcode types.
|
||||
You use the following wrapper to create a quiet zone:
|
||||
|
||||
```golang
|
||||
type QuietZone struct {
|
||||
width int
|
||||
barcode barcode.Barcode
|
||||
}
|
||||
|
||||
func (qz QuietZone) At(x, y int) color.Color {
|
||||
bounds := qz.barcode.Bounds()
|
||||
w := bounds.Dx()
|
||||
h := bounds.Dy()
|
||||
if x < qz.width || x >= w+qz.width || y < qz.width || y >= h+qz.width {
|
||||
return color.White
|
||||
}
|
||||
return wb.barcode.At(x-qz.width, y-qz.width)
|
||||
}
|
||||
|
||||
func (qz QuietZone) Bounds() image.Rectangle {
|
||||
b := qz.barcode.Bounds()
|
||||
return image.Rect(0, 0, b.Dx()+2*qz.width, b.Dy()+2*qz.width)
|
||||
}
|
||||
|
||||
func (qz QuietZone) ColorModel() color.Model {
|
||||
return qz.barcode.ColorModel()
|
||||
}
|
||||
|
||||
func Main() {
|
||||
bc, _ := qr.Encode("Foobar", qr.L, qr.Auto)
|
||||
|
||||
var img image.Image = QuietZone{10, bc}
|
||||
|
||||
png.Encode(file, img)
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue