Refactor to use ColorScheme instead of 'depth' approach

This commit is contained in:
zhaori96 committed 2024-07-31 16:11:52 -03:00
1 parent e966fa7106
commit 30509e0dd7
16 files changed
+83 -81

No files matched your search

+3 -3
View File
@@ -113,7 +113,7 @@ func prepare(content string) (string, error) {
// Encode returns a code39 barcode for the given content
// if includeChecksum is set to true, a checksum character is calculated and added to the content
func EncodeWithDepth(content string, includeChecksum bool, fullASCIIMode bool, depth int) (barcode.BarcodeIntCS, error) {
func EncodeWithColor(content string, includeChecksum bool, fullASCIIMode bool, color barcode.ColorScheme) (barcode.BarcodeIntCS, error) {
if fullASCIIMode {
var err error
content, err = prepare(content)
@@ -148,11 +148,11 @@ func EncodeWithDepth(content string, includeChecksum bool, fullASCIIMode bool, d
if err != nil {
checkSum = 0
}
return utils.New1DCodeIntCheckSumWithDepth(barcode.TypeCode39, content, result, int(checkSum), depth), nil
return utils.New1DCodeIntCheckSumWithColor(barcode.TypeCode39, content, result, int(checkSum), color), nil
}
// Encode returns a code39 barcode for the given content
// if includeChecksum is set to true, a checksum character is calculated and added to the content
func Encode(content string, includeChecksum bool, fullASCIIMode bool) (barcode.BarcodeIntCS, error) {
return EncodeWithDepth(content, includeChecksum, fullASCIIMode, 16)
return EncodeWithColor(content, includeChecksum, fullASCIIMode, barcode.ColorScheme16)
}