codabarcode.go 620 B

123456789101112131415161718192021222324252627282930313233343536
  1. package codabar
  2. import (
  3. "github.com/boombuler/barcode"
  4. "github.com/boombuler/barcode/utils"
  5. "image"
  6. "image/color"
  7. )
  8. type codabarcode struct {
  9. *utils.BitList
  10. content string
  11. }
  12. func (c *codabarcode) Content() string {
  13. return c.content
  14. }
  15. func (c *codabarcode) Metadata() barcode.Metadata {
  16. return barcode.Metadata{"Codabar", 1}
  17. }
  18. func (c *codabarcode) ColorModel() color.Model {
  19. return color.Gray16Model
  20. }
  21. func (c *codabarcode) Bounds() image.Rectangle {
  22. return image.Rect(0, 0, c.Len(), 1)
  23. }
  24. func (c *codabarcode) At(x, y int) color.Color {
  25. if c.GetBit(x) {
  26. return color.Black
  27. }
  28. return color.White
  29. }