...
1
2 package utils
3
4 import (
5 "image"
6 "image/color"
7
8 "github.com/boombuler/barcode"
9 )
10
11 type base1DCode struct {
12 *BitList
13 kind string
14 content string
15 }
16
17 type base1DCodeIntCS struct {
18 base1DCode
19 checksum int
20 }
21
22 func (c *base1DCode) Content() string {
23 return c.content
24 }
25
26 func (c *base1DCode) Metadata() barcode.Metadata {
27 return barcode.Metadata{c.kind, 1}
28 }
29
30 func (c *base1DCode) ColorModel() color.Model {
31 return color.Gray16Model
32 }
33
34 func (c *base1DCode) Bounds() image.Rectangle {
35 return image.Rect(0, 0, c.Len(), 1)
36 }
37
38 func (c *base1DCode) At(x, y int) color.Color {
39 if c.GetBit(x) {
40 return color.Black
41 }
42 return color.White
43 }
44
45 func (c *base1DCodeIntCS) CheckSum() int {
46 return c.checksum
47 }
48
49
50 func New1DCodeIntCheckSum(codeKind, content string, bars *BitList, checksum int) barcode.BarcodeIntCS {
51 return &base1DCodeIntCS{base1DCode{bars, codeKind, content}, checksum}
52 }
53
54
55 func New1DCode(codeKind, content string, bars *BitList) barcode.Barcode {
56 return &base1DCode{bars, codeKind, content}
57 }
58
View as plain text