Documentation
¶
Overview ¶
Package qrcode provides primitives for generating and manipulating QR codes, including support for embedding center icons and exporting to multiple formats.
Package qrcode provides primitives for generating and manipulating QR codes, including support for embedding center icons and exporting to multiple formats.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidMime = errors.New("invalid mime type")
ErrInvalidMime is returned when an unsupported Mime type is provided.
Functions ¶
This section is empty.
Types ¶
type CarbonFiberBox ¶ added in v1.2.0
type CarbonFiberBox struct {
// contains filtered or unexported fields
}
CarbonFiberBox represents a box that generates a carbon fiber texture pattern.
func (*CarbonFiberBox) Image ¶ added in v1.2.0
func (c *CarbonFiberBox) Image() image.Image
Image generates and returns a new image.Image containing a simulated carbon fiber texture. The pattern is created using alternating shades of dark gray blocks based on the configured size of the CarbonFiberBox.
type IconBox ¶ added in v1.2.0
type IconBox interface {
// Image returns the image.Image to be used as the icon's background.
Image() image.Image
}
IconBox defines the interface for the background container of the icon. Any type implementing this interface can be used to provide the background image.
func NewCarbonFiberBox ¶ added in v1.2.0
NewCarbonFiberBox creates and returns a new CarbonFiberBox with the specified size. It returns an IconBox interface implementation.
type Metadata ¶
type Metadata struct {
Dimensions int
}
Metadata holds structural information about the generated QR code.
type QRCode ¶
type QRCode interface {
image.Image
// Content returns the raw string data encoded in the QR code.
Content() string
// Metadata returns technical details about the QR code structure.
Metadata() Metadata
// SetIcon overlays an image (logo) in the center of the QR code.
// It handles the icon scaling and optional background box rendering.
SetIcon(icon io.Reader, box ...IconBox)
// Image encodes the QR code into a specific Mime format and writes it to w.
Image(w io.Writer, m Mime) error
// Scale resizes the current QR Code to a new width and height.
Scale(width, height int) QRCode
}
QRCode represents a QR code image with its associated content and metadata. It implements the image.Image interface.
func Encode ¶
Encode generates a high-recovery (High) QR Code from the given content. The options parameter is variadic and optional, allowing customization of the QR code's size and color palette.
If no options are provided, or if the specified size is less than 256, it defaults to a size of 1024x1024 pixels. If no custom color is specified within the options, [color.DefaultPalette] is used for the foreground and background.
It returns a QRCode interface containing the generated RGBA image and the original content, or an error if the generation fails.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package color provides tools for defining and generating high-contrast color palettes suitable for QR codes and other visual elements.
|
Package color provides tools for defining and generating high-contrast color palettes suitable for QR codes and other visual elements. |
|
Package encoder provides functionality for generating, formatting, and exporting QR codes.
|
Package encoder provides functionality for generating, formatting, and exporting QR codes. |