code.go 640 B

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