code.go 604 B

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