refactor base1DCode methods to use utility functions for color models and colors
This commit is contained in:
		
							parent
							
								
									e8e52a74a7
								
							
						
					
					
						commit
						f3630e1cd4
					
				@ -12,6 +12,7 @@ type base1DCode struct {
 | 
			
		||||
	*BitList
 | 
			
		||||
	kind    string
 | 
			
		||||
	content string
 | 
			
		||||
	depth   int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type base1DCodeIntCS struct {
 | 
			
		||||
@ -28,7 +29,7 @@ func (c *base1DCode) Metadata() barcode.Metadata {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *base1DCode) ColorModel() color.Model {
 | 
			
		||||
	return color.Gray16Model
 | 
			
		||||
	return ColorModel(c.depth)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *base1DCode) Bounds() image.Rectangle {
 | 
			
		||||
@ -37,9 +38,9 @@ func (c *base1DCode) Bounds() image.Rectangle {
 | 
			
		||||
 | 
			
		||||
func (c *base1DCode) At(x, y int) color.Color {
 | 
			
		||||
	if c.GetBit(x) {
 | 
			
		||||
		return color.Black
 | 
			
		||||
		return BlackColor(c.depth)
 | 
			
		||||
	}
 | 
			
		||||
	return color.White
 | 
			
		||||
	return WhiteColor(c.depth)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *base1DCodeIntCS) CheckSum() int {
 | 
			
		||||
@ -48,10 +49,20 @@ func (c *base1DCodeIntCS) CheckSum() int {
 | 
			
		||||
 | 
			
		||||
// New1DCodeIntCheckSum creates a new 1D barcode where the bars are represented by the bits in the bars BitList
 | 
			
		||||
func New1DCodeIntCheckSum(codeKind, content string, bars *BitList, checksum int) barcode.BarcodeIntCS {
 | 
			
		||||
	return &base1DCodeIntCS{base1DCode{bars, codeKind, content}, checksum}
 | 
			
		||||
	return &base1DCodeIntCS{base1DCode{bars, codeKind, content, 16}, checksum}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// New1DCodeIntCheckSum creates a new 1D barcode where the bars are represented by the bits in the bars BitList
 | 
			
		||||
func New1DCodeIntCheckSumWithDepth(codeKind, content string, bars *BitList, checksum int, depth int) barcode.BarcodeIntCS {
 | 
			
		||||
	return &base1DCodeIntCS{base1DCode{bars, codeKind, content, depth}, checksum}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// New1DCode creates a new 1D barcode where the bars are represented by the bits in the bars BitList
 | 
			
		||||
func New1DCode(codeKind, content string, bars *BitList) barcode.Barcode {
 | 
			
		||||
	return &base1DCode{bars, codeKind, content}
 | 
			
		||||
	return &base1DCode{bars, codeKind, content, 16}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// New1DCode creates a new 1D barcode where the bars are represented by the bits in the bars BitList
 | 
			
		||||
func New1DCodeWithDepth(codeKind, content string, bars *BitList, depth int) barcode.Barcode {
 | 
			
		||||
	return &base1DCode{bars, codeKind, content, depth}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user