Update github.com/pquerna/otp from untagged to v1.2.0 (#11358)
This commit is contained in:
parent
57b6f83191
commit
43bb85908d
16 changed files with 192 additions and 54 deletions
1
vendor/github.com/boombuler/barcode/.gitignore
generated
vendored
Normal file
1
vendor/github.com/boombuler/barcode/.gitignore
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.vscode/
|
49
vendor/github.com/boombuler/barcode/README.md
generated
vendored
49
vendor/github.com/boombuler/barcode/README.md
generated
vendored
|
@ -1,18 +1,53 @@
|
|||
##Introduction##
|
||||
[](https://gitter.im/golang-barcode/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
## Introduction ##
|
||||
|
||||
This is a package for GO which can be used to create different types of barcodes.
|
||||
|
||||
##Supported Barcode Types##
|
||||
## Supported Barcode Types ##
|
||||
* 2 of 5
|
||||
* Aztec Code
|
||||
* Codabar
|
||||
* Code 128
|
||||
* Code 39
|
||||
* EAN 8
|
||||
* EAN 13
|
||||
* Code 93
|
||||
* Datamatrix
|
||||
* QR Codes
|
||||
* 2 of 5
|
||||
* EAN 13
|
||||
* EAN 8
|
||||
* PDF 417
|
||||
* QR Code
|
||||
|
||||
##Documentation##
|
||||
## Example ##
|
||||
|
||||
This is a simple example on how to create a QR-Code and write it to a png-file
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"image/png"
|
||||
"os"
|
||||
|
||||
"github.com/boombuler/barcode"
|
||||
"github.com/boombuler/barcode/qr"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create the barcode
|
||||
qrCode, _ := qr.Encode("Hello World", qr.M, qr.Auto)
|
||||
|
||||
// Scale the barcode to 200x200 pixels
|
||||
qrCode, _ = barcode.Scale(qrCode, 200, 200)
|
||||
|
||||
// create the output file
|
||||
file, _ := os.Create("qrcode.png")
|
||||
defer file.Close()
|
||||
|
||||
// encode the barcode as png
|
||||
png.Encode(file, qrCode)
|
||||
}
|
||||
```
|
||||
|
||||
## Documentation ##
|
||||
See [GoDoc](https://godoc.org/github.com/boombuler/barcode)
|
||||
|
||||
To create a barcode use the Encode function from one of the subpackages.
|
||||
|
|
21
vendor/github.com/boombuler/barcode/barcode.go
generated
vendored
21
vendor/github.com/boombuler/barcode/barcode.go
generated
vendored
|
@ -2,6 +2,21 @@ package barcode
|
|||
|
||||
import "image"
|
||||
|
||||
const (
|
||||
TypeAztec = "Aztec"
|
||||
TypeCodabar = "Codabar"
|
||||
TypeCode128 = "Code 128"
|
||||
TypeCode39 = "Code 39"
|
||||
TypeCode93 = "Code 93"
|
||||
TypeDataMatrix = "DataMatrix"
|
||||
TypeEAN8 = "EAN 8"
|
||||
TypeEAN13 = "EAN 13"
|
||||
TypePDF = "PDF417"
|
||||
TypeQR = "QR Code"
|
||||
Type2of5 = "2 of 5"
|
||||
Type2of5Interleaved = "2 of 5 (interleaved)"
|
||||
)
|
||||
|
||||
// Contains some meta information about a barcode
|
||||
type Metadata struct {
|
||||
// the name of the barcode kind
|
||||
|
@ -17,5 +32,11 @@ type Barcode interface {
|
|||
Metadata() Metadata
|
||||
// the data that was encoded in this barcode
|
||||
Content() string
|
||||
}
|
||||
|
||||
// Additional interface that some barcodes might implement to provide
|
||||
// the value of its checksum.
|
||||
type BarcodeIntCS interface {
|
||||
Barcode
|
||||
CheckSum() int
|
||||
}
|
||||
|
|
1
vendor/github.com/boombuler/barcode/go.mod
generated
vendored
Normal file
1
vendor/github.com/boombuler/barcode/go.mod
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
module github.com/boombuler/barcode
|
6
vendor/github.com/boombuler/barcode/qr/qrcode.go
generated
vendored
6
vendor/github.com/boombuler/barcode/qr/qrcode.go
generated
vendored
|
@ -20,7 +20,7 @@ func (qr *qrcode) Content() string {
|
|||
}
|
||||
|
||||
func (qr *qrcode) Metadata() barcode.Metadata {
|
||||
return barcode.Metadata{"QR Code", 2}
|
||||
return barcode.Metadata{barcode.TypeQR, 2}
|
||||
}
|
||||
|
||||
func (qr *qrcode) ColorModel() color.Model {
|
||||
|
@ -46,10 +46,6 @@ func (qr *qrcode) Set(x, y int, val bool) {
|
|||
qr.data.SetBit(x*qr.dimension+y, val)
|
||||
}
|
||||
|
||||
func (qr *qrcode) CheckSum() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (qr *qrcode) calcPenalty() uint {
|
||||
return qr.calcPenaltyRule1() + qr.calcPenaltyRule2() + qr.calcPenaltyRule3() + qr.calcPenaltyRule4()
|
||||
}
|
||||
|
|
37
vendor/github.com/boombuler/barcode/scaledbarcode.go
generated
vendored
37
vendor/github.com/boombuler/barcode/scaledbarcode.go
generated
vendored
|
@ -16,6 +16,10 @@ type scaledBarcode struct {
|
|||
rect image.Rectangle
|
||||
}
|
||||
|
||||
type intCSscaledBC struct {
|
||||
scaledBarcode
|
||||
}
|
||||
|
||||
func (bc *scaledBarcode) Content() string {
|
||||
return bc.wrapped.Content()
|
||||
}
|
||||
|
@ -36,8 +40,11 @@ func (bc *scaledBarcode) At(x, y int) color.Color {
|
|||
return bc.wrapperFunc(x, y)
|
||||
}
|
||||
|
||||
func (bc *scaledBarcode) CheckSum() int {
|
||||
return bc.wrapped.CheckSum()
|
||||
func (bc *intCSscaledBC) CheckSum() int {
|
||||
if cs, ok := bc.wrapped.(BarcodeIntCS); ok {
|
||||
return cs.CheckSum()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Scale returns a resized barcode with the given width and height.
|
||||
|
@ -52,6 +59,19 @@ func Scale(bc Barcode, width, height int) (Barcode, error) {
|
|||
return nil, errors.New("unsupported barcode format")
|
||||
}
|
||||
|
||||
func newScaledBC(wrapped Barcode, wrapperFunc wrapFunc, rect image.Rectangle) Barcode {
|
||||
result := &scaledBarcode{
|
||||
wrapped: wrapped,
|
||||
wrapperFunc: wrapperFunc,
|
||||
rect: rect,
|
||||
}
|
||||
|
||||
if _, ok := wrapped.(BarcodeIntCS); ok {
|
||||
return &intCSscaledBC{*result}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func scale2DCode(bc Barcode, width, height int) (Barcode, error) {
|
||||
orgBounds := bc.Bounds()
|
||||
orgWidth := orgBounds.Max.X - orgBounds.Min.X
|
||||
|
@ -59,7 +79,7 @@ func scale2DCode(bc Barcode, width, height int) (Barcode, error) {
|
|||
|
||||
factor := int(math.Min(float64(width)/float64(orgWidth), float64(height)/float64(orgHeight)))
|
||||
if factor <= 0 {
|
||||
return nil, fmt.Errorf("can not scale barcode to an image smaller then %dx%d", orgWidth, orgHeight)
|
||||
return nil, fmt.Errorf("can not scale barcode to an image smaller than %dx%d", orgWidth, orgHeight)
|
||||
}
|
||||
|
||||
offsetX := (width - (orgWidth * factor)) / 2
|
||||
|
@ -77,11 +97,11 @@ func scale2DCode(bc Barcode, width, height int) (Barcode, error) {
|
|||
return bc.At(x, y)
|
||||
}
|
||||
|
||||
return &scaledBarcode{
|
||||
return newScaledBC(
|
||||
bc,
|
||||
wrap,
|
||||
image.Rect(0, 0, width, height),
|
||||
}, nil
|
||||
), nil
|
||||
}
|
||||
|
||||
func scale1DCode(bc Barcode, width, height int) (Barcode, error) {
|
||||
|
@ -90,7 +110,7 @@ func scale1DCode(bc Barcode, width, height int) (Barcode, error) {
|
|||
factor := int(float64(width) / float64(orgWidth))
|
||||
|
||||
if factor <= 0 {
|
||||
return nil, fmt.Errorf("can not scale barcode to an image smaller then %dx1", orgWidth)
|
||||
return nil, fmt.Errorf("can not scale barcode to an image smaller than %dx1", orgWidth)
|
||||
}
|
||||
offsetX := (width - (orgWidth * factor)) / 2
|
||||
|
||||
|
@ -106,10 +126,9 @@ func scale1DCode(bc Barcode, width, height int) (Barcode, error) {
|
|||
return bc.At(x, 0)
|
||||
}
|
||||
|
||||
return &scaledBarcode{
|
||||
return newScaledBC(
|
||||
bc,
|
||||
wrap,
|
||||
image.Rect(0, 0, width, height),
|
||||
}, nil
|
||||
|
||||
), nil
|
||||
}
|
||||
|
|
21
vendor/github.com/boombuler/barcode/utils/base1dcode.go
generated
vendored
21
vendor/github.com/boombuler/barcode/utils/base1dcode.go
generated
vendored
|
@ -10,8 +10,12 @@ import (
|
|||
|
||||
type base1DCode struct {
|
||||
*BitList
|
||||
kind string
|
||||
content string
|
||||
kind string
|
||||
content string
|
||||
}
|
||||
|
||||
type base1DCodeIntCS struct {
|
||||
base1DCode
|
||||
checksum int
|
||||
}
|
||||
|
||||
|
@ -38,11 +42,16 @@ func (c *base1DCode) At(x, y int) color.Color {
|
|||
return color.White
|
||||
}
|
||||
|
||||
func (c *base1DCode) CheckSum() int {
|
||||
func (c *base1DCodeIntCS) CheckSum() int {
|
||||
return c.checksum
|
||||
}
|
||||
|
||||
// New1DCode creates a new 1D barcode where the bars are represented by the bits in the bars BitList
|
||||
func New1DCode(codeKind, content string, bars *BitList, checksum int) barcode.Barcode {
|
||||
return &base1DCode{bars, codeKind, content, checksum}
|
||||
// New1DCodeIntCheckSum creates a new 1D barcode where the bars are represented by the bits in the bars BitList
|
||||
func New1DCodeIntCheckSum(codeKind, content string, bars *BitList, checksum int) barcode.BarcodeIntCS {
|
||||
return &base1DCodeIntCS{base1DCode{bars, codeKind, content}, checksum}
|
||||
}
|
||||
|
||||
// New1DCode creates a new 1D barcode where the bars are represented by the bits in the bars BitList
|
||||
func New1DCode(codeKind, content string, bars *BitList) barcode.Barcode {
|
||||
return &base1DCode{bars, codeKind, content}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue