@@ -155,8 +155,8 @@ func getCodeIndexList(content []rune) *utils.BitList {
155
155
return result
156
156
}
157
157
158
- // Encode creates a Code 128 barcode for the given content
159
- func Encode (content string ) (barcode.BarcodeIntCS , error ) {
158
+ // Encode creates a Code 128 barcode for the given content and color scheme
159
+ func EncodeWithColor (content string , color barcode. ColorScheme ) (barcode.BarcodeIntCS , error ) {
160
160
contentRunes := strToRunes (content )
161
161
if len (contentRunes ) <= 0 || len (contentRunes ) > 80 {
162
162
return nil , fmt .Errorf ("content length should be between 1 and 80 runes but got %d" , len (contentRunes ))
@@ -180,10 +180,19 @@ func Encode(content string) (barcode.BarcodeIntCS, error) {
180
180
sum = sum % 103
181
181
result .AddBit (encodingTable [sum ]... )
182
182
result .AddBit (encodingTable [stopSymbol ]... )
183
- return utils .New1DCodeIntCheckSum (barcode .TypeCode128 , content , result , sum ), nil
183
+ return utils .New1DCodeIntCheckSumWithColor (barcode .TypeCode128 , content , result , sum , color ), nil
184
+ }
185
+
186
+ // Encode creates a Code 128 barcode for the given content
187
+ func Encode (content string ) (barcode.BarcodeIntCS , error ) {
188
+ return EncodeWithColor (content , barcode .ColorScheme16 )
184
189
}
185
190
186
191
func EncodeWithoutChecksum (content string ) (barcode.Barcode , error ) {
192
+ return EncodeWithoutChecksumWithColor (content , barcode .ColorScheme16 )
193
+ }
194
+
195
+ func EncodeWithoutChecksumWithColor (content string , color barcode.ColorScheme ) (barcode.Barcode , error ) {
187
196
contentRunes := strToRunes (content )
188
197
if len (contentRunes ) <= 0 || len (contentRunes ) > 80 {
189
198
return nil , fmt .Errorf ("content length should be between 1 and 80 runes but got %d" , len (contentRunes ))
@@ -199,5 +208,5 @@ func EncodeWithoutChecksum(content string) (barcode.Barcode, error) {
199
208
result .AddBit (encodingTable [idx ]... )
200
209
}
201
210
result .AddBit (encodingTable [stopSymbol ]... )
202
- return utils .New1DCode (barcode .TypeCode128 , content , result ), nil
211
+ return utils .New1DCodeWithColor (barcode .TypeCode128 , content , result , color ), nil
203
212
}
0 commit comments