MCPcopy Create free account
hub / github.com/boombuler/barcode / EncodeWithColor

Function EncodeWithColor

qr/encoder.go:58–69  ·  view source on GitHub ↗

Encode returns a QR barcode with the given content and color scheme, error correction level and uses the given encoding

(content string, level ErrorCorrectionLevel, mode Encoding, color barcode.ColorScheme)

Source from the content-addressed store, hash-verified

56
57// Encode returns a QR barcode with the given content and color scheme, error correction level and uses the given encoding
58func EncodeWithColor(content string, level ErrorCorrectionLevel, mode Encoding, color barcode.ColorScheme) (barcode.Barcode, error) {
59 bits, vi, err := mode.getEncoder()(content, level)
60 if err != nil {
61 return nil, err
62 }
63
64 blocks := splitToBlocks(bits.IterateBytes(), vi)
65 data := blocks.interleave(vi)
66 result := render(data, vi, color)
67 result.content = content
68 return result, nil
69}
70
71func Encode(content string, level ErrorCorrectionLevel, mode Encoding) (barcode.Barcode, error) {
72 return EncodeWithColor(content, level, mode, barcode.ColorScheme16)

Callers 1

EncodeFunction · 0.70

Calls 5

splitToBlocksFunction · 0.85
getEncoderMethod · 0.80
IterateBytesMethod · 0.80
interleaveMethod · 0.80
renderFunction · 0.70

Tested by

no test coverage detected