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 }