Refactor to use ColorScheme instead of 'depth' approach
This commit is contained in:
1 parent
e966fa7106
commit
30509e0dd7
16 files changed
+83
-81
No files matched your search
+3
-3
@@ -156,7 +156,7 @@ func getCodeIndexList(content []rune) *utils.BitList {
|
||||
}
|
||||
|
||||
// Encode creates a Code 128 barcode for the given content
|
||||
func EncodeWithDepth(content string, depth int) (barcode.BarcodeIntCS, error) {
|
||||
func EncodeWithColor(content string, color barcode.ColorScheme) (barcode.BarcodeIntCS, error) {
|
||||
contentRunes := strToRunes(content)
|
||||
if len(contentRunes) <= 0 || len(contentRunes) > 80 {
|
||||
return nil, fmt.Errorf("content length should be between 1 and 80 runes but got %d", len(contentRunes))
|
||||
@@ -180,12 +180,12 @@ func EncodeWithDepth(content string, depth int) (barcode.BarcodeIntCS, error) {
|
||||
sum = sum % 103
|
||||
result.AddBit(encodingTable[sum]...)
|
||||
result.AddBit(encodingTable[stopSymbol]...)
|
||||
return utils.New1DCodeIntCheckSumWithDepth(barcode.TypeCode128, content, result, sum, depth), nil
|
||||
return utils.New1DCodeIntCheckSumWithColor(barcode.TypeCode128, content, result, sum, color), nil
|
||||
}
|
||||
|
||||
// Encode creates a Code 128 barcode for the given content
|
||||
func Encode(content string) (barcode.BarcodeIntCS, error) {
|
||||
return EncodeWithDepth(content, 16)
|
||||
return EncodeWithColor(content, barcode.ColorScheme16)
|
||||
}
|
||||
|
||||
func EncodeWithoutChecksum(content string) (barcode.Barcode, error) {
|
||||
|
||||
Reference in new issue
Block a user