Add EncodeWithChecksum color overload

This commit is contained in:
zhaori96 2024-08-02 12:30:54 -03:00
parent b1129f9d8b
commit a8e67c5d16
1 changed files with 5 additions and 1 deletions

View File

@ -189,6 +189,10 @@ func Encode(content string) (barcode.BarcodeIntCS, error) {
} }
func EncodeWithoutChecksum(content string) (barcode.Barcode, error) { func EncodeWithoutChecksum(content string) (barcode.Barcode, error) {
return EncodeWithoutChecksumWithColor(content, barcode.ColorScheme16)
}
func EncodeWithoutChecksumWithColor(content string, color barcode.ColorScheme) (barcode.Barcode, error) {
contentRunes := strToRunes(content) contentRunes := strToRunes(content)
if len(contentRunes) <= 0 || len(contentRunes) > 80 { 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)) return nil, fmt.Errorf("content length should be between 1 and 80 runes but got %d", len(contentRunes))
@ -204,5 +208,5 @@ func EncodeWithoutChecksum(content string) (barcode.Barcode, error) {
result.AddBit(encodingTable[idx]...) result.AddBit(encodingTable[idx]...)
} }
result.AddBit(encodingTable[stopSymbol]...) result.AddBit(encodingTable[stopSymbol]...)
return utils.New1DCode(barcode.TypeCode128, content, result), nil return utils.New1DCodeWithColor(barcode.TypeCode128, content, result, color), nil
} }