forked from yeqown/go-qrcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: export encode option as Config; update documentation; add an ex…
…ample for NewWithConfig API
- Loading branch information
Showing
6 changed files
with
78 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
package qrcode | ||
|
||
func defaultOutputEncoderOption() *outputEncodingOptions { | ||
return &outputEncodingOptions{ | ||
encMode: EncModeAuto, | ||
ecLevel: ErrorCorrectionQuart, | ||
// DefaultConfig with EncMode = EncModeAuto, EcLevel = ErrorCorrectionQuart | ||
func DefaultConfig() *Config { | ||
return &outputEncodingOption{ | ||
EncMode: EncModeAuto, | ||
EcLevel: ErrorCorrectionQuart, | ||
} | ||
} | ||
|
||
type outputEncodingOptions struct { | ||
// Config alias of outputEncodingOption. | ||
type Config = outputEncodingOption | ||
|
||
// encMode specifies which encMode to use | ||
encMode encMode | ||
type outputEncodingOption struct { | ||
|
||
// ecLevel specifies which ecLevel to use | ||
ecLevel ecLevel | ||
// EncMode specifies which encMode to use | ||
EncMode encMode | ||
|
||
// EcLevel specifies which ecLevel to use | ||
EcLevel ecLevel | ||
|
||
// PS: The version (which implicitly defines the byte capacity of the qrcode) is dynamically selected at runtime | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
import "github.com/yeqown/go-qrcode" | ||
|
||
func main() { | ||
config := qrcode.Config{ | ||
EncMode: qrcode.EncModeByte, | ||
EcLevel: qrcode.ErrorCorrectionQuart, | ||
} | ||
qrc, err := qrcode.NewWithConfig("github.com/yeqown/qo-qrcode", &config, qrcode.WithQRWidth(40)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
if err = qrc.Save("./a.png"); err != nil { | ||
panic(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters