cleanup
This commit is contained in:
1 parent
a4167688a0
commit
9741f0ff8d
12 files changed
+143
-270
No files matched your search
@@ -1,40 +0,0 @@
|
||||
package code39
|
||||
|
||||
import (
|
||||
"github.com/boombuler/barcode"
|
||||
"github.com/boombuler/barcode/utils"
|
||||
"image"
|
||||
"image/color"
|
||||
)
|
||||
|
||||
type code struct {
|
||||
*utils.BitList
|
||||
content string
|
||||
}
|
||||
|
||||
func newCode() *code {
|
||||
return &code{new(utils.BitList), ""}
|
||||
}
|
||||
|
||||
func (c *code) Content() string {
|
||||
return c.content
|
||||
}
|
||||
|
||||
func (c *code) Metadata() barcode.Metadata {
|
||||
return barcode.Metadata{"Code39", 1}
|
||||
}
|
||||
|
||||
func (c *code) ColorModel() color.Model {
|
||||
return color.Gray16Model
|
||||
}
|
||||
|
||||
func (c *code) Bounds() image.Rectangle {
|
||||
return image.Rect(0, 0, c.Len(), 1)
|
||||
}
|
||||
|
||||
func (c *code) At(x, y int) color.Color {
|
||||
if c.GetBit(x) {
|
||||
return color.Black
|
||||
}
|
||||
return color.White
|
||||
}
|
||||
+5
-7
@@ -3,6 +3,7 @@ package code39
|
||||
import (
|
||||
"errors"
|
||||
"github.com/boombuler/barcode"
|
||||
"github.com/boombuler/barcode/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -91,22 +92,19 @@ func Encode(content string, includeChecksum bool) (barcode.Barcode, error) {
|
||||
}
|
||||
data += "*"
|
||||
|
||||
cd := newCode()
|
||||
cd.content = content
|
||||
result := new(utils.BitList)
|
||||
|
||||
for i, r := range data {
|
||||
if i != 0 {
|
||||
cd.AddBit(false)
|
||||
result.AddBit(false)
|
||||
}
|
||||
|
||||
info, ok := encodeTable[r]
|
||||
if !ok {
|
||||
return nil, errors.New("invalid data")
|
||||
}
|
||||
for _, bit := range info.data {
|
||||
cd.AddBit(bit)
|
||||
}
|
||||
result.AddBit(info.data...)
|
||||
}
|
||||
|
||||
return cd, nil
|
||||
return utils.New1DCode("Code 39", content, result), nil
|
||||
}
|
||||
Reference in new issue
Block a user