| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package ean
- import (
- "github.com/boombuler/barcode"
- "image"
- "image/color"
- )
- type eancode struct {
- *barcode.BitList
- content string
- }
- func newEANCode(isEAN8 bool) *eancode {
- capacity := 95
- if isEAN8 {
- capacity = 67
- }
- return &eancode{barcode.NewBitList(capacity), ""}
- }
- func (c *eancode) Content() string {
- return c.content
- }
- func (c *eancode) Metadata() barcode.Metadata {
- if c.Len() == 67 {
- return barcode.Metadata{"EAN 8", 1}
- }
- return barcode.Metadata{"EAN 13", 1}
- }
- func (c *eancode) ColorModel() color.Model {
- return color.Gray16Model
- }
- func (c *eancode) Bounds() image.Rectangle {
- return image.Rect(0, 0, c.Len(), 1)
- }
- func (c *eancode) At(x, y int) color.Color {
- if c.GetBit(x) {
- return color.Black
- }
- return color.White
- }
|